/bp-core/classes/class-bp-component.php

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