Changeset 10356 for trunk/src/bp-core/bp-core-component.php
- Timestamp:
- 11/15/2015 07:57:03 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-component.php
r10110 r10356 19 19 * internally by BuddyPress to create the bundled components, but can be 20 20 * extended to create other really neat things. 21 *22 * @package BuddyPress23 * @subpackage Component24 21 * 25 22 * @since 1.5.0 … … 161 158 public function start( $id = '', $name = '', $path = '', $params = array() ) { 162 159 163 // Internal identifier of component 160 // Internal identifier of component. 164 161 $this->id = $id; 165 162 166 // Internal component name 163 // Internal component name. 167 164 $this->name = $name; 168 165 169 // Path for includes 166 // Path for includes. 170 167 $this->path = $path; 171 168 172 // Miscellaneous component parameters that need to be set early on 169 // Miscellaneous component parameters that need to be set early on. 173 170 if ( ! empty( $params ) ) { 174 // Sets the position for our menu under the WP Toolbar's "My Account" menu 171 // Sets the position for our menu under the WP Toolbar's "My Account" menu. 175 172 if ( ! empty( $params['adminbar_myaccount_order'] ) ) { 176 173 $this->adminbar_myaccount_order = (int) $params['adminbar_myaccount_order']; 177 174 } 178 175 179 // Register features 176 // Register features. 180 177 if ( ! empty( $params['features'] ) ) { 181 178 $this->features = array_map( 'sanitize_title', (array) $params['features'] ); … … 186 183 } 187 184 188 // Set defaults if not passed 185 // Set defaults if not passed. 189 186 } else { 190 // new component menus are added before the settings menu if not set187 // New component menus are added before the settings menu if not set. 191 188 $this->adminbar_myaccount_order = 90; 192 189 } 193 190 194 // Move on to the next step 191 // Move on to the next step. 195 192 $this->setup_actions(); 196 193 } … … 222 219 public function setup_globals( $args = array() ) { 223 220 224 /** Slugs *************************************************************/ 221 /** Slugs ************************************************************ 222 */ 225 223 226 224 // If a WP directory page exists for the component, it should … … 293 291 $this->notification_callback = apply_filters( 'bp_' . $this->id . '_notification_callback', $r['notification_callback'] ); 294 292 295 // Set the global table names, if applicable 293 // Set the global table names, if applicable. 296 294 if ( ! empty( $r['global_tables'] ) ) { 297 295 $this->register_global_tables( $r['global_tables'] ); 298 296 } 299 297 300 // Set the metadata table, if applicable 298 // Set the metadata table, if applicable. 301 299 if ( ! empty( $r['meta_tables'] ) ) { 302 300 $this->register_meta_tables( $r['meta_tables'] ); 303 301 } 304 302 305 /** BuddyPress ********************************************************/ 306 307 // Register this component in the loaded components array 303 /** BuddyPress ******************************************************* 304 */ 305 306 // Register this component in the loaded components array. 308 307 buddypress()->loaded_components[$this->slug] = $this->id; 309 308 … … 350 349 public function includes( $includes = array() ) { 351 350 352 // Bail if no files to include 351 // Bail if no files to include. 353 352 if ( ! empty( $includes ) ) { 354 353 $slashed_path = trailingslashit( $this->path ); 355 354 356 // Loop through files to be included 355 // Loop through files to be included. 357 356 foreach ( (array) $includes as $file ) { 358 357 359 358 $paths = array( 360 359 361 // Passed with no extension 360 // Passed with no extension. 362 361 'bp-' . $this->id . '/bp-' . $this->id . '-' . $file . '.php', 363 362 'bp-' . $this->id . '-' . $file . '.php', 364 363 'bp-' . $this->id . '/' . $file . '.php', 365 364 366 // Passed with extension 365 // Passed with extension. 367 366 $file, 368 367 'bp-' . $this->id . '-' . $file, … … 399 398 public function setup_actions() { 400 399 401 // Setup globals 400 // Setup globals. 402 401 add_action( 'bp_setup_globals', array( $this, 'setup_globals' ), 10 ); 403 402 404 // Set up canonical stack 403 // Set up canonical stack. 405 404 add_action( 'bp_setup_canonical_stack', array( $this, 'setup_canonical_stack' ), 10 ); 406 405 … … 412 411 add_action( 'bp_include', array( $this, 'includes' ), 8 ); 413 412 414 // Setup navigation 413 // Setup navigation. 415 414 add_action( 'bp_setup_nav', array( $this, 'setup_nav' ), 10 ); 416 415 417 // Setup WP Toolbar menus 416 // Setup WP Toolbar menus. 418 417 add_action( 'bp_setup_admin_bar', array( $this, 'setup_admin_bar' ), $this->adminbar_myaccount_order ); 419 418 420 // Setup component title 419 // Setup component title. 421 420 add_action( 'bp_setup_title', array( $this, 'setup_title' ), 10 ); 422 421 423 // Setup cache groups 422 // Setup cache groups. 424 423 add_action( 'bp_setup_cache_groups', array( $this, 'setup_cache_groups' ), 10 ); 425 424 426 // Register post types 425 // Register post types. 427 426 add_action( 'bp_register_post_types', array( $this, 'register_post_types' ), 10 ); 428 427 429 // Register taxonomies 428 // Register taxonomies. 430 429 add_action( 'bp_register_taxonomies', array( $this, 'register_taxonomies' ), 10 ); 431 430 432 // Add the rewrite tags 431 // Add the rewrite tags. 433 432 add_action( 'bp_add_rewrite_tags', array( $this, 'add_rewrite_tags' ), 10 ); 434 433 435 // Add the rewrite rules 434 // Add the rewrite rules. 436 435 add_action( 'bp_add_rewrite_rules', array( $this, 'add_rewrite_rules' ), 10 ); 437 436 438 // Add the permalink structure 437 // Add the permalink structure. 439 438 add_action( 'bp_add_permastructs', array( $this, 'add_permastructs' ), 10 ); 440 439 441 // Allow components to parse the main query 440 // Allow components to parse the main query. 442 441 add_action( 'bp_parse_query', array( $this, 'parse_query' ), 10 ); 443 442 444 // Generate rewrite rules 443 // Generate rewrite rules. 445 444 add_action( 'bp_generate_rewrite_rules', array( $this, 'generate_rewrite_rules' ), 10 ); 446 445 … … 478 477 public function setup_nav( $main_nav = array(), $sub_nav = array() ) { 479 478 480 // No sub nav items without a main nav item 479 // No sub nav items without a main nav item. 481 480 if ( !empty( $main_nav ) ) { 482 481 bp_core_new_nav_item( $main_nav ); 483 482 484 // Sub nav items are not required 483 // Sub nav items are not required. 485 484 if ( !empty( $sub_nav ) ) { 486 485 foreach( (array) $sub_nav as $nav ) { … … 514 513 public function setup_admin_bar( $wp_admin_nav = array() ) { 515 514 516 // Bail if this is an ajax request 515 // Bail if this is an ajax request. 517 516 if ( defined( 'DOING_AJAX' ) ) { 518 517 return; 519 518 } 520 519 521 // Do not proceed if BP_USE_WP_ADMIN_BAR constant is not set or is false 520 // Do not proceed if BP_USE_WP_ADMIN_BAR constant is not set or is false. 522 521 if ( ! bp_use_wp_admin_bar() ) { 523 522 return; … … 538 537 if ( !empty( $wp_admin_nav ) ) { 539 538 540 // Set this objects menus 539 // Set this objects menus. 541 540 $this->admin_menu = $wp_admin_nav; 542 541 543 // Define the WordPress global 542 // Define the WordPress global. 544 543 global $wp_admin_bar; 545 544 546 // Add each admin menu 545 // Add each admin menu. 547 546 foreach( $this->admin_menu as $admin_menu ) { 548 547 $wp_admin_bar->add_menu( $admin_menu ); … … 618 617 $tables = apply_filters( 'bp_' . $this->id . '_global_tables', $tables ); 619 618 620 // Add to the BuddyPress global object 619 // Add to the BuddyPress global object. 621 620 if ( !empty( $tables ) && is_array( $tables ) ) { 622 621 foreach ( $tables as $global_name => $table_name ) { … … 624 623 } 625 624 626 // Keep a record of the metadata tables in the component 625 // Keep a record of the metadata tables in the component. 627 626 $this->global_tables = $tables; 628 627 } … … 671 670 } 672 671 673 // Keep a record of the metadata tables in the component 672 // Keep a record of the metadata tables in the component. 674 673 $this->meta_tables = $tables; 675 674 }
Note: See TracChangeset
for help on using the changeset viewer.