[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-core/classes/ -> class-bp-component.php (source)

   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  
 185              // Register features.
 186              if ( ! empty( $params['features'] ) ) {
 187                  $this->features = array_map( 'sanitize_title', (array) $params['features'] );
 188              }
 189  
 190              if ( ! empty( $params['search_query_arg'] ) ) {
 191                  $this->search_query_arg = sanitize_title( $params['search_query_arg'] );
 192              }
 193  
 194          // Set defaults if not passed.
 195          } else {
 196              // New component menus are added before the settings menu if not set.
 197              $this->adminbar_myaccount_order = 90;
 198          }
 199  
 200          // Move on to the next step.
 201          $this->setup_actions();
 202      }
 203  
 204      /**
 205       * Set up component global variables.
 206       *
 207       * @since 1.5.0
 208       *
 209       *
 210       * @param array $args {
 211       *     All values are optional.
 212       *     @type string   $slug                  The component slug. Used to construct certain URLs, such as 'friends' in
 213       *                                           http://example.com/members/joe/friends/. Default: the value of $this->id.
 214       *     @type string   $root_slug             The component root slug. Note that this value is generally unused if the
 215       *                                           component has a root directory (the slug will be overridden by the
 216       *                                           post_name of the directory page). Default: the slug of the directory page
 217       *                                           if one is found, otherwise an empty string.
 218       *     @type bool     $has_directory         Set to true if the component requires an associated WordPress page.
 219       *     @type callable $notification_callback Optional. The callable function that formats the component's notifications.
 220       *     @type string   $search_term           Optional. The placeholder text in the component directory search box. Eg,
 221       *                                           'Search Groups...'.
 222       *     @type array    $global_tables         Optional. An array of database table names.
 223       *     @type array    $meta_tables           Optional. An array of metadata table names.
 224       * }
 225       */
 226  	public function setup_globals( $args = array() ) {
 227  
 228          /** Slugs ************************************************************
 229           */
 230  
 231          // If a WP directory page exists for the component, it should
 232          // be the default value of 'root_slug'.
 233          $default_root_slug = isset( buddypress()->pages->{$this->id}->slug ) ? buddypress()->pages->{$this->id}->slug : '';
 234  
 235          $r = wp_parse_args( $args, array(
 236              'slug'                  => $this->id,
 237              'root_slug'             => $default_root_slug,
 238              'has_directory'         => false,
 239              'directory_title'       => '',
 240              'notification_callback' => '',
 241              'search_string'         => '',
 242              'global_tables'         => '',
 243              'meta_tables'           => '',
 244          ) );
 245  
 246          /**
 247           * Filters the slug to be used for the permalink URI chunk after root.
 248           *
 249           * @since 1.5.0
 250           *
 251           * @param string $value Slug to use in permalink URI chunk.
 252           */
 253          $this->slug                  = apply_filters( 'bp_' . $this->id . '_slug',                  $r['slug']                  );
 254  
 255          /**
 256           * Filters the slug used for root directory.
 257           *
 258           * @since 1.5.0
 259           *
 260           * @param string $value Root directory slug.
 261           */
 262          $this->root_slug             = apply_filters( 'bp_' . $this->id . '_root_slug',             $r['root_slug']             );
 263  
 264          /**
 265           * Filters the component's top-level directory if available.
 266           *
 267           * @since 1.5.0
 268           *
 269           * @param bool $value Whether or not there is a top-level directory.
 270           */
 271          $this->has_directory         = apply_filters( 'bp_' . $this->id . '_has_directory',         $r['has_directory']         );
 272  
 273          /**
 274           * Filters the component's directory title.
 275           *
 276           * @since 2.0.0
 277           *
 278           * @param string $value Title to use for the directory.
 279           */
 280          $this->directory_title       = apply_filters( 'bp_' . $this->id . '_directory_title',       $r['directory_title']         );
 281  
 282          /**
 283           * Filters the placeholder text for search inputs for component.
 284           *
 285           * @since 1.5.0
 286           *
 287           * @param string $value Name to use in search input placeholders.
 288           */
 289          $this->search_string         = apply_filters( 'bp_' . $this->id . '_search_string',         $r['search_string']         );
 290  
 291          /**
 292           * Filters the callable function that formats the component's notifications.
 293           *
 294           * @since 1.5.0
 295           *
 296           * @param string $value Function callback.
 297           */
 298          $this->notification_callback = apply_filters( 'bp_' . $this->id . '_notification_callback', $r['notification_callback'] );
 299  
 300          // Set the global table names, if applicable.
 301          if ( ! empty( $r['global_tables'] ) ) {
 302              $this->register_global_tables( $r['global_tables'] );
 303          }
 304  
 305          // Set the metadata table, if applicable.
 306          if ( ! empty( $r['meta_tables'] ) ) {
 307              $this->register_meta_tables( $r['meta_tables'] );
 308          }
 309  
 310          /** BuddyPress *******************************************************
 311           */
 312  
 313          // Register this component in the loaded components array.
 314          buddypress()->loaded_components[$this->slug] = $this->id;
 315  
 316          /**
 317           * Fires at the end of the setup_globals method inside BP_Component.
 318           *
 319           * This is a dynamic hook that is based on the component string ID.
 320           *
 321           * @since 1.5.0
 322           */
 323          do_action( 'bp_' . $this->id . '_setup_globals' );
 324      }
 325  
 326      /**
 327       * Include required files.
 328       *
 329       * Please note that, by default, this method is fired on the bp_include
 330       * hook, with priority 8. This is necessary so that core components are
 331       * loaded in time to be available to third-party plugins. However, this
 332       * load order means that third-party plugins whose main files are
 333       * loaded at bp_include with priority 10 (as recommended), will not be
 334       * loaded in time for their includes() method to fire automatically.
 335       *
 336       * For this reason, it is recommended that your plugin has its own
 337       * method or function for requiring necessary files. If you must use
 338       * this method, you will have to call it manually in your constructor
 339       * class, ie
 340       *   $this->includes();
 341       *
 342       * Note that when you pass an array value like 'actions' to includes,
 343       * it looks for the following three files (assuming your component is
 344       * called 'my_component'):
 345       *   - ./actions
 346       *   - ./bp-my_component/actions
 347       *   - ./bp-my_component/bp-my_component-actions.php
 348       *
 349       * @since 1.5.0
 350       *
 351       *
 352       * @param array $includes An array of file names, or file name chunks,
 353       *                        to be parsed and then included.
 354       */
 355  	public function includes( $includes = array() ) {
 356  
 357          // Bail if no files to include.
 358          if ( ! empty( $includes ) ) {
 359              $slashed_path = trailingslashit( $this->path );
 360  
 361              // Loop through files to be included.
 362              foreach ( (array) $includes as $file ) {
 363  
 364                  $paths = array(
 365  
 366                      // Passed with no extension.
 367                      'bp-' . $this->id . '/bp-' . $this->id . '-' . $file  . '.php',
 368                      'bp-' . $this->id . '-' . $file . '.php',
 369                      'bp-' . $this->id . '/' . $file . '.php',
 370  
 371                      // Passed with extension.
 372                      $file,
 373                      'bp-' . $this->id . '-' . $file,
 374                      'bp-' . $this->id . '/' . $file,
 375                  );
 376  
 377                  foreach ( $paths as $path ) {
 378                      if ( @is_file( $slashed_path . $path ) ) {
 379                          require( $slashed_path . $path );
 380                          break;
 381                      }
 382                  }
 383              }
 384          }
 385  
 386          /**
 387           * Fires at the end of the includes method inside BP_Component.
 388           *
 389           * This is a dynamic hook that is based on the component string ID.
 390           *
 391           * @since 1.5.0
 392           */
 393          do_action( 'bp_' . $this->id . '_includes' );
 394      }
 395  
 396      /**
 397       * Late includes method.
 398       *
 399       * Components should include files here only on specific pages using
 400       * conditionals such as {@link bp_is_current_component()}. Intentionally left
 401       * empty.
 402       *
 403       * @since 3.0.0
 404       */
 405  	public function late_includes() {}
 406  
 407      /**
 408       * Set up the actions.
 409       *
 410       * @since 1.5.0
 411       *
 412       */
 413  	public function setup_actions() {
 414  
 415          // Setup globals.
 416          add_action( 'bp_setup_globals',          array( $this, 'setup_globals'          ), 10 );
 417  
 418          // Set up canonical stack.
 419          add_action( 'bp_setup_canonical_stack',  array( $this, 'setup_canonical_stack'  ), 10 );
 420  
 421          // Include required files. Called early to ensure that BP core
 422          // components are loaded before plugins that hook their loader functions
 423          // to bp_include with the default priority of 10. This is for backwards
 424          // compatibility; henceforth, plugins should register themselves by
 425          // extending this base class.
 426          add_action( 'bp_include',                array( $this, 'includes'               ), 8 );
 427  
 428          // Load files conditionally, based on certain pages.
 429          add_action( 'bp_late_include',           array( $this, 'late_includes'          ) );
 430  
 431          // Setup navigation.
 432          add_action( 'bp_setup_nav',              array( $this, 'setup_nav'              ), 10 );
 433  
 434          // Setup WP Toolbar menus.
 435          add_action( 'bp_setup_admin_bar',        array( $this, 'setup_admin_bar'        ), $this->adminbar_myaccount_order );
 436  
 437          // Setup component title.
 438          add_action( 'bp_setup_title',            array( $this, 'setup_title'            ), 10 );
 439  
 440          // Setup cache groups.
 441          add_action( 'bp_setup_cache_groups',     array( $this, 'setup_cache_groups'     ), 10 );
 442  
 443          // Register post types.
 444          add_action( 'bp_register_post_types',    array( $this, 'register_post_types'    ), 10 );
 445  
 446          // Register taxonomies.
 447          add_action( 'bp_register_taxonomies',    array( $this, 'register_taxonomies'    ), 10 );
 448  
 449          // Add the rewrite tags.
 450          add_action( 'bp_add_rewrite_tags',       array( $this, 'add_rewrite_tags'       ), 10 );
 451  
 452          // Add the rewrite rules.
 453          add_action( 'bp_add_rewrite_rules',      array( $this, 'add_rewrite_rules'      ), 10 );
 454  
 455          // Add the permalink structure.
 456          add_action( 'bp_add_permastructs',       array( $this, 'add_permastructs'       ), 10 );
 457  
 458          // Allow components to parse the main query.
 459          add_action( 'bp_parse_query',            array( $this, 'parse_query'            ), 10 );
 460  
 461          // Generate rewrite rules.
 462          add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 );
 463  
 464          // Register BP REST Endpoints
 465          if ( bp_rest_in_buddypress() && bp_rest_api_is_available() ) {
 466              add_action( 'bp_rest_api_init', array( $this, 'rest_api_init' ), 10 );
 467          }
 468  
 469          /**
 470           * Fires at the end of the setup_actions method inside BP_Component.
 471           *
 472           * This is a dynamic hook that is based on the component string ID.
 473           *
 474           * @since 1.5.0
 475           */
 476          do_action( 'bp_' . $this->id . '_setup_actions' );
 477      }
 478  
 479      /**
 480       * Set up the canonical URL stack for this component.
 481       *
 482       * @since 2.1.0
 483       */
 484  	public function setup_canonical_stack() {}
 485  
 486      /**
 487       * Set up component navigation.
 488       *
 489       * @since 1.5.0
 490       *
 491       * @see bp_core_new_nav_item() For a description of the $main_nav
 492       *      parameter formatting.
 493       * @see bp_core_new_subnav_item() For a description of how each item
 494       *      in the $sub_nav parameter array should be formatted.
 495       *
 496       * @param array $main_nav Optional. Passed directly to bp_core_new_nav_item().
 497       *                        See that function for a description.
 498       * @param array $sub_nav  Optional. Multidimensional array, each item in
 499       *                        which is passed to bp_core_new_subnav_item(). See that
 500       *                        function for a description.
 501       */
 502  	public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
 503  
 504          // No sub nav items without a main nav item.
 505          if ( !empty( $main_nav ) ) {
 506              // Always set the component ID.
 507              $main_nav['component_id'] = $this->id;
 508  
 509              bp_core_new_nav_item( $main_nav, 'members' );
 510  
 511              // Sub nav items are not required.
 512              if ( !empty( $sub_nav ) ) {
 513                  foreach( (array) $sub_nav as $nav ) {
 514                      bp_core_new_subnav_item( $nav, 'members' );
 515                  }
 516              }
 517          }
 518  
 519          /**
 520           * Fires at the end of the setup_nav method inside BP_Component.
 521           *
 522           * This is a dynamic hook that is based on the component string ID.
 523           *
 524           * @since 1.5.0
 525           */
 526          do_action( 'bp_' . $this->id . '_setup_nav' );
 527      }
 528  
 529      /**
 530       * Set up the component entries in the WordPress Admin Bar.
 531       *
 532       * @since 1.5.0
 533       *
 534       * @see WP_Admin_Bar::add_menu() for a description of the syntax
 535       *      required by each item in the $wp_admin_nav parameter array.
 536       * @global object $wp_admin_bar
 537       *
 538       * @param array $wp_admin_nav An array of nav item arguments. Each item in this parameter
 539       *                            array is passed to {@link WP_Admin_Bar::add_menu()}.
 540       *                            See that method for a description of the required syntax for
 541       *                            each item.
 542       */
 543  	public function setup_admin_bar( $wp_admin_nav = array() ) {
 544  
 545          // Bail if this is an ajax request.
 546          if ( defined( 'DOING_AJAX' ) ) {
 547              return;
 548          }
 549  
 550          // Do not proceed if BP_USE_WP_ADMIN_BAR constant is not set or is false.
 551          if ( ! bp_use_wp_admin_bar() ) {
 552              return;
 553          }
 554  
 555          /**
 556           * Filters the admin navigation passed into setup_admin_bar.
 557           *
 558           * This is a dynamic hook that is based on the component string ID.
 559           *
 560           * @since 1.9.0
 561           *
 562           * @param array $wp_admin_nav Array of navigation items to add.
 563           */
 564          $wp_admin_nav = apply_filters( 'bp_' . $this->id . '_admin_nav', $wp_admin_nav );
 565  
 566          // Do we have Toolbar menus to add?
 567          if ( !empty( $wp_admin_nav ) ) {
 568              // Fill in position if one wasn't passed for backpat.
 569              $pos = 0;
 570              $not_set_pos = 1;
 571              foreach( $wp_admin_nav as $key => $nav ) {
 572                  if ( ! isset( $nav['position'] ) ) {
 573                      $wp_admin_nav[$key]['position'] = $pos + $not_set_pos;
 574  
 575                      if ( 9 !== $not_set_pos ) {
 576                          ++$not_set_pos;
 577                      }
 578                  } else {
 579                      $pos = $nav['position'];
 580  
 581                      // Reset not set pos to 1
 582                      if ( $pos % 10 === 0 ) {
 583                          $not_set_pos = 1;
 584                      }
 585                  }
 586              }
 587  
 588              // Sort admin nav by position.
 589              $wp_admin_nav = bp_sort_by_key( $wp_admin_nav, 'position', 'num' );
 590  
 591              // Set this objects menus.
 592              $this->admin_menu = $wp_admin_nav;
 593  
 594              // Define the WordPress global.
 595              global $wp_admin_bar;
 596  
 597              // Add each admin menu.
 598              foreach( $this->admin_menu as $admin_menu ) {
 599                  $wp_admin_bar->add_menu( $admin_menu );
 600              }
 601          }
 602  
 603          /**
 604           * Fires at the end of the setup_admin_bar method inside BP_Component.
 605           *
 606           * This is a dynamic hook that is based on the component string ID.
 607           *
 608           * @since 1.5.0
 609           */
 610          do_action( 'bp_' . $this->id . '_setup_admin_bar' );
 611      }
 612  
 613      /**
 614       * Set up the component title.
 615       *
 616       * @since 1.5.0
 617       *
 618       */
 619  	public function setup_title() {
 620  
 621          /**
 622           * Fires in the setup_title method inside BP_Component.
 623           *
 624           * This is a dynamic hook that is based on the component string ID.
 625           *
 626           * @since 1.5.0
 627           */
 628          do_action(  'bp_' . $this->id . '_setup_title' );
 629      }
 630  
 631      /**
 632       * Setup component-specific cache groups.
 633       *
 634       * @since 2.2.0
 635       *
 636       */
 637  	public function setup_cache_groups() {
 638  
 639          /**
 640           * Fires in the setup_cache_groups method inside BP_Component.
 641           *
 642           * This is a dynamic hook that is based on the component string ID.
 643           *
 644           * @since 2.2.0
 645           */
 646          do_action( 'bp_' . $this->id . '_setup_cache_groups' );
 647      }
 648  
 649      /**
 650       * Register global tables for the component, so that it may use WordPress's database API.
 651       *
 652       * @since 2.0.0
 653       *
 654       * @param array $tables Table names to register.
 655       */
 656  	public function register_global_tables( $tables = array() ) {
 657  
 658          /**
 659           * Filters the global tables for the component, so that it may use WordPress' database API.
 660           *
 661           * This is a dynamic hook that is based on the component string ID.
 662           * It allows for component-specific filtering of table names. To filter
 663           * *all* tables, use the 'bp_core_get_table_prefix' filter instead.
 664           *
 665           * @since 1.6.0
 666           */
 667          $tables = apply_filters( 'bp_' . $this->id . '_global_tables', $tables );
 668  
 669          // Add to the BuddyPress global object.
 670          if ( !empty( $tables ) && is_array( $tables ) ) {
 671              foreach ( $tables as $global_name => $table_name ) {
 672                  $this->{$global_name} = $table_name;
 673              }
 674  
 675              // Keep a record of the metadata tables in the component.
 676              $this->global_tables = $tables;
 677          }
 678  
 679          /**
 680           * Fires at the end of the register_global_tables method inside BP_Component.
 681           *
 682           * This is a dynamic hook that is based on the component string ID.
 683           *
 684           * @since 2.0.0
 685           */
 686          do_action( 'bp_' . $this->id . '_register_global_tables' );
 687      }
 688  
 689      /**
 690       * Register component metadata tables.
 691       *
 692       * Metadata tables are registered in the $wpdb global, for
 693       * compatibility with the WordPress metadata API.
 694       *
 695       * @since 2.0.0
 696       *
 697       * @param array $tables Table names to register.
 698       */
 699  	public function register_meta_tables( $tables = array() ) {
 700          global $wpdb;
 701  
 702          /**
 703           * Filters the global meta_tables for the component.
 704           *
 705           * This is a dynamic hook that is based on the component string ID.
 706           * It allows for component-specific filtering of table names. To filter
 707           * *all* tables, use the 'bp_core_get_table_prefix' filter instead.
 708           *
 709           * @since 2.0.0
 710           */
 711          $tables = apply_filters( 'bp_' . $this->id . '_meta_tables', $tables );
 712  
 713          /**
 714           * Add the name of each metadata table to WPDB to allow BuddyPress
 715           * components to play nicely with the WordPress metadata API.
 716           */
 717          if ( !empty( $tables ) && is_array( $tables ) ) {
 718              foreach( $tables as $meta_prefix => $table_name ) {
 719                  $wpdb->{$meta_prefix . 'meta'} = $table_name;
 720              }
 721  
 722              // Keep a record of the metadata tables in the component.
 723              $this->meta_tables = $tables;
 724          }
 725  
 726          /**
 727           * Fires at the end of the register_meta_tables method inside BP_Component.
 728           *
 729           * This is a dynamic hook that is based on the component string ID.
 730           *
 731           * @since 2.0.0
 732           */
 733          do_action( 'bp_' . $this->id . '_register_meta_tables' );
 734      }
 735  
 736      /**
 737       * Set up the component post types.
 738       *
 739       * @since 1.5.0
 740       *
 741       */
 742  	public function register_post_types() {
 743  
 744          /**
 745           * Fires in the register_post_types method inside BP_Component.
 746           *
 747           * This is a dynamic hook that is based on the component string ID.
 748           *
 749           * @since 1.5.0
 750           */
 751          do_action( 'bp_' . $this->id . '_register_post_types' );
 752      }
 753  
 754      /**
 755       * Register component-specific taxonomies.
 756       *
 757       * @since 1.5.0
 758       *
 759       */
 760  	public function register_taxonomies() {
 761  
 762          /**
 763           * Fires in the register_taxonomies method inside BP_Component.
 764           *
 765           * This is a dynamic hook that is based on the component string ID.
 766           *
 767           * @since 1.5.0
 768           */
 769          do_action( 'bp_' . $this->id . '_register_taxonomies' );
 770      }
 771  
 772      /**
 773       * Add any additional rewrite tags.
 774       *
 775       * @since 1.5.0
 776       *
 777       */
 778  	public function add_rewrite_tags() {
 779  
 780          /**
 781           * Fires in the add_rewrite_tags method inside BP_Component.
 782           *
 783           * This is a dynamic hook that is based on the component string ID.
 784           *
 785           * @since 1.5.0
 786           */
 787          do_action( 'bp_' . $this->id . '_add_rewrite_tags' );
 788      }
 789  
 790      /**
 791       * Add any additional rewrite rules.
 792       *
 793       * @since 1.9.0
 794       *
 795       */
 796  	public function add_rewrite_rules() {
 797  
 798          /**
 799           * Fires in the add_rewrite_rules method inside BP_Component.
 800           *
 801           * This is a dynamic hook that is based on the component string ID.
 802           *
 803           * @since 1.9.0
 804           */
 805          do_action( 'bp_' . $this->id . '_add_rewrite_rules' );
 806      }
 807  
 808      /**
 809       * Add any permalink structures.
 810       *
 811       * @since 1.9.0
 812       *
 813       */
 814  	public function add_permastructs() {
 815  
 816          /**
 817           * Fires in the add_permastructs method inside BP_Component.
 818           *
 819           * This is a dynamic hook that is based on the component string ID.
 820           *
 821           * @since 1.9.0
 822           */
 823          do_action( 'bp_' . $this->id . '_add_permastructs' );
 824      }
 825  
 826      /**
 827       * Allow components to parse the main query.
 828       *
 829       * @since 1.9.0
 830       *
 831       *
 832       * @param object $query The main WP_Query.
 833       */
 834  	public function parse_query( $query ) {
 835  
 836          /**
 837           * Fires in the parse_query method inside BP_Component.
 838           *
 839           * This is a dynamic hook that is based on the component string ID.
 840           *
 841           * @since 1.9.0
 842           *
 843           * @param object $query Main WP_Query object. Passed by reference.
 844           */
 845          do_action_ref_array( 'bp_' . $this->id . '_parse_query', array( &$query ) );
 846      }
 847  
 848      /**
 849       * Generate any additional rewrite rules.
 850       *
 851       * @since 1.5.0
 852       *
 853       */
 854  	public function generate_rewrite_rules() {
 855  
 856          /**
 857           * Fires in the generate_rewrite_rules method inside BP_Component.
 858           *
 859           * This is a dynamic hook that is based on the component string ID.
 860           *
 861           * @since 1.5.0
 862           */
 863          do_action( 'bp_' . $this->id . '_generate_rewrite_rules' );
 864      }
 865  
 866      /**
 867       * Init the BP REST API.
 868       *
 869       * @since 5.0.0
 870       */
 871  	public function rest_api_init() {
 872  
 873          /**
 874           * Fires in the rest_api_init method inside BP_Component.
 875           *
 876           * This is a dynamic hook that is based on the component string ID.
 877           *
 878           * @since 5.0.0
 879           */
 880          do_action( 'bp_' . $this->id . '_rest_api_init' );
 881      }
 882  }
 883  endif; // BP_Component.


Generated: Sat Sep 21 01:01:46 2019 Cross-referenced by PHPXref 0.7.1