Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/05/2016 04:26:30 AM (10 years ago)
Author:
boonebgorges
Message:

Move bp-core classes to their own files.

See #6870.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-component.php

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