BP_Component

BuddyPress Component Class.

Defined (1)

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

/bp-core/classes/class-bp-component.php  
  1. class BP_Component { 
  2.  
  3. /** Variables *************************************************************/ 
  4.  
  5. /** 
  6. * Translatable name for the component. 
  7. * @internal 
  8. * @var string $name 
  9. */ 
  10. public $name = ''; 
  11.  
  12. /** 
  13. * Unique ID for the component. 
  14. * @since 1.5.0 
  15. * @var string $id 
  16. */ 
  17. public $id = ''; 
  18.  
  19. /** 
  20. * Unique slug for the component, for use in query strings and URLs. 
  21. * @since 1.5.0 
  22. * @var string $slug 
  23. */ 
  24. public $slug = ''; 
  25.  
  26. /** 
  27. * Does the component need a top-level directory? 
  28. * @since 1.5.0 
  29. * @var bool $has_directory 
  30. */ 
  31. public $has_directory = false; 
  32.  
  33. /** 
  34. * The path to the component's files. 
  35. * @since 1.5.0 
  36. * @var string $path 
  37. */ 
  38. public $path = ''; 
  39.  
  40. /** 
  41. * The WP_Query loop for this component. 
  42. * @since 1.5.0 
  43. * @var WP_Query $query 
  44. */ 
  45. public $query = false; 
  46.  
  47. /** 
  48. * The current ID of the queried object. 
  49. * @since 1.5.0 
  50. * @var string $current_id 
  51. */ 
  52. public $current_id = ''; 
  53.  
  54. /** 
  55. * Callback for formatting notifications. 
  56. * @since 1.5.0 
  57. * @var callable $notification_callback 
  58. */ 
  59. public $notification_callback = ''; 
  60.  
  61. /** 
  62. * WordPress Toolbar links. 
  63. * @since 1.5.0 
  64. * @var array $admin_menu 
  65. */ 
  66. public $admin_menu = ''; 
  67.  
  68. /** 
  69. * Placeholder text for component directory search box. 
  70. * @since 1.6.0 
  71. * @var string $search_string 
  72. */ 
  73. public $search_string = ''; 
  74.  
  75. /** 
  76. * Root slug for the component. 
  77. * @since 1.6.0 
  78. * @var string $root_slug 
  79. */ 
  80. public $root_slug = ''; 
  81.  
  82. /** 
  83. * Metadata tables for the component (if applicable). 
  84. * @since 2.0.0 
  85. * @var array 
  86. */ 
  87. public $meta_tables = array(); 
  88.  
  89. /** 
  90. * Global tables for the component (if applicable). 
  91. * @since 2.0.0 
  92. * @var array 
  93. */ 
  94. public $global_tables = array(); 
  95.  
  96. /** 
  97. * Query argument for component search URLs. 
  98. * @since 2.4.0 
  99. * @var string 
  100. */ 
  101. public $search_query_arg = 's'; 
  102.  
  103. /** Methods ***************************************************************/ 
  104.  
  105. /** 
  106. * Component loader. 
  107. * @since 1.5.0 
  108. * @since 1.9.0 Added $params as a parameter. 
  109. * @since 2.3.0 Added $params['features'] as a configurable value. 
  110. * @since 2.4.0 Added $params['search_query_arg'] as a configurable value. 
  111. * @param string $id Unique ID. Letters, numbers, and underscores only. 
  112. * @param string $name Unique name. This should be a translatable name, eg. 
  113. * __( 'Groups', 'buddypress' ). 
  114. * @param string $path The file path for the component's files. Used by {@link BP_Component::includes()}. 
  115. * @param array $params { 
  116. * Additional parameters used by the component. 
  117. * @type int $adminbar_myaccount_order Set the position for our menu under the WP Toolbar's "My Account menu". 
  118. * @type array $features An array of feature names. This is used to load additional files from your 
  119. * component directory and for feature active checks. eg. array( 'awesome' ) 
  120. * would look for a file called "bp-{$this->id}-awesome.php" and you could use 
  121. * bp_is_active( $this->id, 'awesome' ) to determine if the feature is active. 
  122. * @type string $search_query_arg String to be used as the query argument in component search URLs. 
  123. * } 
  124. */ 
  125. public function start( $id = '', $name = '', $path = '', $params = array() ) { 
  126.  
  127. // Internal identifier of component. 
  128. $this->id = $id; 
  129.  
  130. // Internal component name. 
  131. $this->name = $name; 
  132.  
  133. // Path for includes. 
  134. $this->path = $path; 
  135.  
  136. // Miscellaneous component parameters that need to be set early on. 
  137. if ( ! empty( $params ) ) { 
  138. // Sets the position for our menu under the WP Toolbar's "My Account" menu. 
  139. if ( ! empty( $params['adminbar_myaccount_order'] ) ) { 
  140. $this->adminbar_myaccount_order = (int) $params['adminbar_myaccount_order']; 
  141.  
  142. // Register features. 
  143. if ( ! empty( $params['features'] ) ) { 
  144. $this->features = array_map( 'sanitize_title', (array) $params['features'] ); 
  145.  
  146. if ( ! empty( $params['search_query_arg'] ) ) { 
  147. $this->search_query_arg = sanitize_title( $params['search_query_arg'] ); 
  148.  
  149. // Set defaults if not passed. 
  150. } else { 
  151. // New component menus are added before the settings menu if not set. 
  152. $this->adminbar_myaccount_order = 90; 
  153.  
  154. // Move on to the next step. 
  155. $this->setup_actions(); 
  156.  
  157. /** 
  158. * Set up component global variables. 
  159. * @since 1.5.0 
  160. * @param array $args { 
  161. * All values are optional. 
  162. * @type string $slug The component slug. Used to construct certain URLs, such as 'friends' in 
  163. * http://example.com/members/joe/friends/. Default: the value of $this->id. 
  164. * @type string $root_slug The component root slug. Note that this value is generally unused if the 
  165. * component has a root directory (the slug will be overridden by the 
  166. * post_name of the directory page). Default: the slug of the directory page 
  167. * if one is found, otherwise an empty string. 
  168. * @type bool $has_directory Set to true if the component requires an associated WordPress page. 
  169. * @type callable $notification_callback Optional. The callable function that formats the component's notifications. 
  170. * @type string $search_term Optional. The placeholder text in the component directory search box. Eg,  
  171. * 'Search Groups...'. 
  172. * @type array $global_tables Optional. An array of database table names. 
  173. * @type array $meta_tables Optional. An array of metadata table names. 
  174. * } 
  175. */ 
  176. public function setup_globals( $args = array() ) { 
  177.  
  178. /** Slugs ************************************************************ 
  179. */ 
  180.  
  181. // If a WP directory page exists for the component, it should 
  182. // be the default value of 'root_slug'. 
  183. $default_root_slug = isset( buddypress()->pages->{$this->id}->slug ) ? buddypress()->pages->{$this->id}->slug : ''; 
  184.  
  185. $r = wp_parse_args( $args, array( 
  186. 'slug' => $this->id,  
  187. 'root_slug' => $default_root_slug,  
  188. 'has_directory' => false,  
  189. 'directory_title' => '',  
  190. 'notification_callback' => '',  
  191. 'search_string' => '',  
  192. 'global_tables' => '',  
  193. 'meta_tables' => '',  
  194. ) ); 
  195.  
  196. /** 
  197. * Filters the slug to be used for the permalink URI chunk after root. 
  198. * @since 1.5.0 
  199. * @param string $value Slug to use in permalink URI chunk. 
  200. */ 
  201. $this->slug = apply_filters( 'bp_' . $this->id . '_slug', $r['slug'] ); 
  202.  
  203. /** 
  204. * Filters the slug used for root directory. 
  205. * @since 1.5.0 
  206. * @param string $value Root directory slug. 
  207. */ 
  208. $this->root_slug = apply_filters( 'bp_' . $this->id . '_root_slug', $r['root_slug'] ); 
  209.  
  210. /** 
  211. * Filters the component's top-level directory if available. 
  212. * @since 1.5.0 
  213. * @param bool $value Whether or not there is a top-level directory. 
  214. */ 
  215. $this->has_directory = apply_filters( 'bp_' . $this->id . '_has_directory', $r['has_directory'] ); 
  216.  
  217. /** 
  218. * Filters the component's directory title. 
  219. * @since 2.0.0 
  220. * @param string $value Title to use for the directory. 
  221. */ 
  222. $this->directory_title = apply_filters( 'bp_' . $this->id . '_directory_title', $r['directory_title'] ); 
  223.  
  224. /** 
  225. * Filters the placeholder text for search inputs for component. 
  226. * @since 1.5.0 
  227. * @param string $value Name to use in search input placeholders. 
  228. */ 
  229. $this->search_string = apply_filters( 'bp_' . $this->id . '_search_string', $r['search_string'] ); 
  230.  
  231. /** 
  232. * Filters the callable function that formats the component's notifications. 
  233. * @since 1.5.0 
  234. * @param string $value Function callback. 
  235. */ 
  236. $this->notification_callback = apply_filters( 'bp_' . $this->id . '_notification_callback', $r['notification_callback'] ); 
  237.  
  238. // Set the global table names, if applicable. 
  239. if ( ! empty( $r['global_tables'] ) ) { 
  240. $this->register_global_tables( $r['global_tables'] ); 
  241.  
  242. // Set the metadata table, if applicable. 
  243. if ( ! empty( $r['meta_tables'] ) ) { 
  244. $this->register_meta_tables( $r['meta_tables'] ); 
  245.  
  246. /** BuddyPress ******************************************************* 
  247. */ 
  248.  
  249. // Register this component in the loaded components array. 
  250. buddypress()->loaded_components[$this->slug] = $this->id; 
  251.  
  252. /** 
  253. * Fires at the end of the setup_globals method inside BP_Component. 
  254. * This is a dynamic hook that is based on the component string ID. 
  255. * @since 1.5.0 
  256. */ 
  257. do_action( 'bp_' . $this->id . '_setup_globals' ); 
  258.  
  259. /** 
  260. * Include required files. 
  261. * Please note that, by default, this method is fired on the bp_include 
  262. * hook, with priority 8. This is necessary so that core components are 
  263. * loaded in time to be available to third-party plugins. However, this 
  264. * load order means that third-party plugins whose main files are 
  265. * loaded at bp_include with priority 10 (as recommended), will not be 
  266. * loaded in time for their includes() method to fire automatically. 
  267. * For this reason, it is recommended that your plugin has its own 
  268. * method or function for requiring necessary files. If you must use 
  269. * this method, you will have to call it manually in your constructor 
  270. * class, ie 
  271. * $this->includes(); 
  272. * Note that when you pass an array value like 'actions' to includes,  
  273. * it looks for the following three files (assuming your component is 
  274. * called 'my_component'): 
  275. * - ./actions 
  276. * - ./bp-my_component/actions 
  277. * - ./bp-my_component/bp-my_component-actions.php 
  278. * @since 1.5.0 
  279. * @param array $includes An array of file names, or file name chunks,  
  280. * to be parsed and then included. 
  281. */ 
  282. public function includes( $includes = array() ) { 
  283.  
  284. // Bail if no files to include. 
  285. if ( ! empty( $includes ) ) { 
  286. $slashed_path = trailingslashit( $this->path ); 
  287.  
  288. // Loop through files to be included. 
  289. foreach ( (array) $includes as $file ) { 
  290.  
  291. $paths = array( 
  292.  
  293. // Passed with no extension. 
  294. 'bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php',  
  295. 'bp-' . $this->id . '-' . $file . '.php',  
  296. 'bp-' . $this->id . '/' . $file . '.php',  
  297.  
  298. // Passed with extension. 
  299. $file,  
  300. 'bp-' . $this->id . '-' . $file,  
  301. 'bp-' . $this->id . '/' . $file,  
  302. ); 
  303.  
  304. foreach ( $paths as $path ) { 
  305. if ( @is_file( $slashed_path . $path ) ) { 
  306. require( $slashed_path . $path ); 
  307. break; 
  308.  
  309. /** 
  310. * Fires at the end of the includes method inside BP_Component. 
  311. * This is a dynamic hook that is based on the component string ID. 
  312. * @since 1.5.0 
  313. */ 
  314. do_action( 'bp_' . $this->id . '_includes' ); 
  315.  
  316. /** 
  317. * Set up the actions. 
  318. * @since 1.5.0 
  319. */ 
  320. public function setup_actions() { 
  321.  
  322. // Setup globals. 
  323. add_action( 'bp_setup_globals', array( $this, 'setup_globals' ), 10 ); 
  324.  
  325. // Set up canonical stack. 
  326. add_action( 'bp_setup_canonical_stack', array( $this, 'setup_canonical_stack' ), 10 ); 
  327.  
  328. // Include required files. Called early to ensure that BP core 
  329. // components are loaded before plugins that hook their loader functions 
  330. // to bp_include with the default priority of 10. This is for backwards 
  331. // compatibility; henceforth, plugins should register themselves by 
  332. // extending this base class. 
  333. add_action( 'bp_include', array( $this, 'includes' ), 8 ); 
  334.  
  335. // Setup navigation. 
  336. add_action( 'bp_setup_nav', array( $this, 'setup_nav' ), 10 ); 
  337.  
  338. // Setup WP Toolbar menus. 
  339. add_action( 'bp_setup_admin_bar', array( $this, 'setup_admin_bar' ), $this->adminbar_myaccount_order ); 
  340.  
  341. // Setup component title. 
  342. add_action( 'bp_setup_title', array( $this, 'setup_title' ), 10 ); 
  343.  
  344. // Setup cache groups. 
  345. add_action( 'bp_setup_cache_groups', array( $this, 'setup_cache_groups' ), 10 ); 
  346.  
  347. // Register post types. 
  348. add_action( 'bp_register_post_types', array( $this, 'register_post_types' ), 10 ); 
  349.  
  350. // Register taxonomies. 
  351. add_action( 'bp_register_taxonomies', array( $this, 'register_taxonomies' ), 10 ); 
  352.  
  353. // Add the rewrite tags. 
  354. add_action( 'bp_add_rewrite_tags', array( $this, 'add_rewrite_tags' ), 10 ); 
  355.  
  356. // Add the rewrite rules. 
  357. add_action( 'bp_add_rewrite_rules', array( $this, 'add_rewrite_rules' ), 10 ); 
  358.  
  359. // Add the permalink structure. 
  360. add_action( 'bp_add_permastructs', array( $this, 'add_permastructs' ), 10 ); 
  361.  
  362. // Allow components to parse the main query. 
  363. add_action( 'bp_parse_query', array( $this, 'parse_query' ), 10 ); 
  364.  
  365. // Generate rewrite rules. 
  366. add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 ); 
  367.  
  368. /** 
  369. * Fires at the end of the setup_actions method inside BP_Component. 
  370. * This is a dynamic hook that is based on the component string ID. 
  371. * @since 1.5.0 
  372. */ 
  373. do_action( 'bp_' . $this->id . '_setup_actions' ); 
  374.  
  375. /** 
  376. * Set up the canonical URL stack for this component. 
  377. * @since 2.1.0 
  378. */ 
  379. public function setup_canonical_stack() {} 
  380.  
  381. /** 
  382. * Set up component navigation. 
  383. * @since 1.5.0 
  384. * @see bp_core_new_nav_item() For a description of the $main_nav 
  385. * parameter formatting. 
  386. * @see bp_core_new_subnav_item() For a description of how each item 
  387. * in the $sub_nav parameter array should be formatted. 
  388. * @param array $main_nav Optional. Passed directly to bp_core_new_nav_item(). 
  389. * See that function for a description. 
  390. * @param array $sub_nav Optional. Multidimensional array, each item in 
  391. * which is passed to bp_core_new_subnav_item(). See that 
  392. * function for a description. 
  393. */ 
  394. public function setup_nav( $main_nav = array(), $sub_nav = array() ) { 
  395.  
  396. // No sub nav items without a main nav item. 
  397. if ( !empty( $main_nav ) ) { 
  398. bp_core_new_nav_item( $main_nav, 'members' ); 
  399.  
  400. // Sub nav items are not required. 
  401. if ( !empty( $sub_nav ) ) { 
  402. foreach( (array) $sub_nav as $nav ) { 
  403. bp_core_new_subnav_item( $nav, 'members' ); 
  404.  
  405. /** 
  406. * Fires at the end of the setup_nav method inside BP_Component. 
  407. * This is a dynamic hook that is based on the component string ID. 
  408. * @since 1.5.0 
  409. */ 
  410. do_action( 'bp_' . $this->id . '_setup_nav' ); 
  411.  
  412. /** 
  413. * Set up the component entries in the WordPress Admin Bar. 
  414. * @since 1.5.0 
  415. * @see WP_Admin_Bar::add_menu() for a description of the syntax 
  416. * required by each item in the $wp_admin_nav parameter array. 
  417. * @global object $wp_admin_bar 
  418. * @param array $wp_admin_nav An array of nav item arguments. Each item in this parameter 
  419. * array is passed to {@link WP_Admin_Bar::add_menu()}. 
  420. * See that method for a description of the required syntax for 
  421. * each item. 
  422. */ 
  423. public function setup_admin_bar( $wp_admin_nav = array() ) { 
  424.  
  425. // Bail if this is an ajax request. 
  426. if ( defined( 'DOING_AJAX' ) ) { 
  427. return; 
  428.  
  429. // Do not proceed if BP_USE_WP_ADMIN_BAR constant is not set or is false. 
  430. if ( ! bp_use_wp_admin_bar() ) { 
  431. return; 
  432.  
  433. /** 
  434. * Filters the admin navigation passed into setup_admin_bar. 
  435. * This is a dynamic hook that is based on the component string ID. 
  436. * @since 1.9.0 
  437. * @param array $wp_admin_nav Array of navigation items to add. 
  438. */ 
  439. $wp_admin_nav = apply_filters( 'bp_' . $this->id . '_admin_nav', $wp_admin_nav ); 
  440.  
  441. // Do we have Toolbar menus to add? 
  442. if ( !empty( $wp_admin_nav ) ) { 
  443. // Fill in position if one wasn't passed for backpat. 
  444. $pos = 0; 
  445. $not_set_pos = 1; 
  446. foreach( $wp_admin_nav as $key => $nav ) { 
  447. if ( ! isset( $nav['position'] ) ) { 
  448. $wp_admin_nav[$key]['position'] = $pos + $not_set_pos; 
  449.  
  450. if ( 9 !== $not_set_pos ) { 
  451. ++$not_set_pos; 
  452. } else { 
  453. $pos = $nav['position']; 
  454.  
  455. // Reset not set pos to 1 
  456. if ( $pos % 10 === 0 ) { 
  457. $not_set_pos = 1; 
  458.  
  459. // Sort admin nav by position. 
  460. $wp_admin_nav = bp_sort_by_key( $wp_admin_nav, 'position', 'num' ); 
  461.  
  462. // Set this objects menus. 
  463. $this->admin_menu = $wp_admin_nav; 
  464.  
  465. // Define the WordPress global. 
  466. global $wp_admin_bar; 
  467.  
  468. // Add each admin menu. 
  469. foreach( $this->admin_menu as $admin_menu ) { 
  470. $wp_admin_bar->add_menu( $admin_menu ); 
  471.  
  472. /** 
  473. * Fires at the end of the setup_admin_bar method inside BP_Component. 
  474. * This is a dynamic hook that is based on the component string ID. 
  475. * @since 1.5.0 
  476. */ 
  477. do_action( 'bp_' . $this->id . '_setup_admin_bar' ); 
  478.  
  479. /** 
  480. * Set up the component title. 
  481. * @since 1.5.0 
  482. */ 
  483. public function setup_title() { 
  484.  
  485. /** 
  486. * Fires in the setup_title method inside BP_Component. 
  487. * This is a dynamic hook that is based on the component string ID. 
  488. * @since 1.5.0 
  489. */ 
  490. do_action( 'bp_' . $this->id . '_setup_title' ); 
  491.  
  492. /** 
  493. * Setup component-specific cache groups. 
  494. * @since 2.2.0 
  495. */ 
  496. public function setup_cache_groups() { 
  497.  
  498. /** 
  499. * Fires in the setup_cache_groups method inside BP_Component. 
  500. * This is a dynamic hook that is based on the component string ID. 
  501. * @since 2.2.0 
  502. */ 
  503. do_action( 'bp_' . $this->id . '_setup_cache_groups' ); 
  504.  
  505. /** 
  506. * Register global tables for the component, so that it may use WordPress's database API. 
  507. * @since 2.0.0 
  508. * @param array $tables Table names to register. 
  509. */ 
  510. public function register_global_tables( $tables = array() ) { 
  511.  
  512. /** 
  513. * Filters the global tables for the component, so that it may use WordPress' database API. 
  514. * This is a dynamic hook that is based on the component string ID. 
  515. * It allows for component-specific filtering of table names. To filter 
  516. * *all* tables, use the 'bp_core_get_table_prefix' filter instead. 
  517. * @since 1.6.0 
  518. */ 
  519. $tables = apply_filters( 'bp_' . $this->id . '_global_tables', $tables ); 
  520.  
  521. // Add to the BuddyPress global object. 
  522. if ( !empty( $tables ) && is_array( $tables ) ) { 
  523. foreach ( $tables as $global_name => $table_name ) { 
  524. $this->$global_name = $table_name; 
  525.  
  526. // Keep a record of the metadata tables in the component. 
  527. $this->global_tables = $tables; 
  528.  
  529. /** 
  530. * Fires at the end of the register_global_tables method inside BP_Component. 
  531. * This is a dynamic hook that is based on the component string ID. 
  532. * @since 2.0.0 
  533. */ 
  534. do_action( 'bp_' . $this->id . '_register_global_tables' ); 
  535.  
  536. /** 
  537. * Register component metadata tables. 
  538. * Metadata tables are registered in the $wpdb global, for 
  539. * compatibility with the WordPress metadata API. 
  540. * @since 2.0.0 
  541. * @param array $tables Table names to register. 
  542. */ 
  543. public function register_meta_tables( $tables = array() ) { 
  544. global $wpdb; 
  545.  
  546. /** 
  547. * Filters the global meta_tables for the component. 
  548. * This is a dynamic hook that is based on the component string ID. 
  549. * It allows for component-specific filtering of table names. To filter 
  550. * *all* tables, use the 'bp_core_get_table_prefix' filter instead. 
  551. * @since 2.0.0 
  552. */ 
  553. $tables = apply_filters( 'bp_' . $this->id . '_meta_tables', $tables ); 
  554.  
  555. /** 
  556. * Add the name of each metadata table to WPDB to allow BuddyPress 
  557. * components to play nicely with the WordPress metadata API. 
  558. */ 
  559. if ( !empty( $tables ) && is_array( $tables ) ) { 
  560. foreach( $tables as $meta_prefix => $table_name ) { 
  561. $wpdb->{$meta_prefix . 'meta'} = $table_name; 
  562.  
  563. // Keep a record of the metadata tables in the component. 
  564. $this->meta_tables = $tables; 
  565.  
  566. /** 
  567. * Fires at the end of the register_meta_tables method inside BP_Component. 
  568. * This is a dynamic hook that is based on the component string ID. 
  569. * @since 2.0.0 
  570. */ 
  571. do_action( 'bp_' . $this->id . '_register_meta_tables' ); 
  572.  
  573. /** 
  574. * Set up the component post types. 
  575. * @since 1.5.0 
  576. */ 
  577. public function register_post_types() { 
  578.  
  579. /** 
  580. * Fires in the register_post_types method inside BP_Component. 
  581. * This is a dynamic hook that is based on the component string ID. 
  582. * @since 1.5.0 
  583. */ 
  584. do_action( 'bp_' . $this->id . '_register_post_types' ); 
  585.  
  586. /** 
  587. * Register component-specific taxonomies. 
  588. * @since 1.5.0 
  589. */ 
  590. public function register_taxonomies() { 
  591.  
  592. /** 
  593. * Fires in the register_taxonomies method inside BP_Component. 
  594. * This is a dynamic hook that is based on the component string ID. 
  595. * @since 1.5.0 
  596. */ 
  597. do_action( 'bp_' . $this->id . '_register_taxonomies' ); 
  598.  
  599. /** 
  600. * Add any additional rewrite tags. 
  601. * @since 1.5.0 
  602. */ 
  603. public function add_rewrite_tags() { 
  604.  
  605. /** 
  606. * Fires in the add_rewrite_tags method inside BP_Component. 
  607. * This is a dynamic hook that is based on the component string ID. 
  608. * @since 1.5.0 
  609. */ 
  610. do_action( 'bp_' . $this->id . '_add_rewrite_tags' ); 
  611.  
  612. /** 
  613. * Add any additional rewrite rules. 
  614. * @since 1.9.0 
  615. */ 
  616. public function add_rewrite_rules() { 
  617.  
  618. /** 
  619. * Fires in the add_rewrite_rules method inside BP_Component. 
  620. * This is a dynamic hook that is based on the component string ID. 
  621. * @since 1.9.0 
  622. */ 
  623. do_action( 'bp_' . $this->id . '_add_rewrite_rules' ); 
  624.  
  625. /** 
  626. * Add any permalink structures. 
  627. * @since 1.9.0 
  628. */ 
  629. public function add_permastructs() { 
  630.  
  631. /** 
  632. * Fires in the add_permastructs method inside BP_Component. 
  633. * This is a dynamic hook that is based on the component string ID. 
  634. * @since 1.9.0 
  635. */ 
  636. do_action( 'bp_' . $this->id . '_add_permastructs' ); 
  637.  
  638. /** 
  639. * Allow components to parse the main query. 
  640. * @since 1.9.0 
  641. * @param object $query The main WP_Query. 
  642. */ 
  643. public function parse_query( $query ) { 
  644.  
  645. /** 
  646. * Fires in the parse_query method inside BP_Component. 
  647. * This is a dynamic hook that is based on the component string ID. 
  648. * @since 1.9.0 
  649. * @param object $query Main WP_Query object. Passed by reference. 
  650. */ 
  651. do_action_ref_array( 'bp_' . $this->id . '_parse_query', array( &$query ) ); 
  652.  
  653. /** 
  654. * Generate any additional rewrite rules. 
  655. * @since 1.5.0 
  656. */ 
  657. public function generate_rewrite_rules() { 
  658.  
  659. /** 
  660. * Fires in the generate_rewrite_rules method inside BP_Component. 
  661. * This is a dynamic hook that is based on the component string ID. 
  662. * @since 1.5.0 
  663. */ 
  664. do_action( 'bp_' . $this->id . '_generate_rewrite_rules' );