bp_forums_bbpress_install

The BuddyPress bp forums bbpress install function.

Description

bp_forums_bbpress_install( (string) $location = '' ); 

Parameters (1)

0. $location — Optional. (string) => ''
The location.

Usage

  1. if ( !function_exists( 'bp_forums_bbpress_install' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/deprecated/1.7.php'; 
  3.  
  4. // The location. 
  5. $location = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_forums_bbpress_install($location); 
  9.  

Defined (1)

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

/bp-forums/deprecated/1.7.php  
  1. function bp_forums_bbpress_install( $location = '' ) { 
  2. global $wpdb, $bbdb; 
  3.  
  4. check_admin_referer( 'bp_forums_new_install_init' ); 
  5.  
  6. if ( empty( $location ) ) { 
  7. $location = ABSPATH . 'bb-config.php'; 
  8.  
  9. $bp =buddypress); 
  10.  
  11. // Create the bb-config.php file. 
  12. $initial_write = bp_forums_bbpress_write
  13. $bp->plugin_dir . '/bp-forums/bbpress/bb-config-sample.php',  
  14. $location,  
  15. array( 
  16. "define( 'BBDB_NAME', " => array( "'bbpress'", "'" . DB_NAME . "'" ),  
  17. "define( 'BBDB_USER', " => array( "'username'", "'" . DB_USER . "'" ),  
  18. "define( 'BBDB_PASSWO" => array( "'password'", "'" . DB_PASSWORD . "'" ),  
  19. "define( 'BBDB_HOST', " => array( "'localhost'", "'" . DB_HOST . "'" ),  
  20. "define( 'BBDB_CHARSE" => array( "'utf8'", "'" . DB_CHARSET . "'" ),  
  21. "define( 'BBDB_COLLAT" => array( "''", "'" . DB_COLLATE . "'" ),  
  22. "define( 'BB_AUTH_KEY" => array( "'put your unique phrase here'", "'" . addslashes( AUTH_KEY ) . "'" ),  
  23. "define( 'BB_SECURE_A" => array( "'put your unique phrase here'", "'" . addslashes( SECURE_AUTH_KEY ) . "'" ),  
  24. "define( 'BB_LOGGED_I" => array( "'put your unique phrase here'", "'" . addslashes( LOGGED_IN_KEY ) . "'" ),  
  25. "define( 'BB_NONCE_KE" => array( "'put your unique phrase here'", "'" . addslashes( NONCE_KEY ) . "'" ),  
  26. "\$bb_table_prefix = '" => array( "'bb_'", "'" . $bp->table_prefix . "bb_'" ),  
  27. "define( 'BB_LANG', '" => array( "''", "'" . get_locale() . "'" ) 
  28. ); 
  29.  
  30. // Add the custom user and usermeta entries to the config file. 
  31. if ( $initial_write == 1 ) { 
  32. $file = file_get_contents( $location ); 
  33. } else { 
  34. $file = &$initial_write; 
  35.  
  36. $file = trim( $file ); 
  37. if ( '?>' == substr( $file, -2, 2 ) ) { 
  38. $file = substr( $file, 0, -2 ); 
  39.  
  40. $file .= "\n" . '$bb->custom_user_table = \'' . $wpdb->users . '\';'; 
  41. $file .= "\n" . '$bb->custom_user_meta_table = \'' . $wpdb->usermeta . '\';'; 
  42. $file .= "\n\n" . '$bb->uri = \'' . $bp->plugin_url . '/bp-forums/bbpress/\';'; 
  43. $file .= "\n" . '$bb->name = \'' . get_blog_option( bp_get_root_blog_id(), 'blogname' ) . ' ' . __( 'Forums', buddypress ) . '\';'; 
  44.  
  45. if ( is_multisite() ) { 
  46. $file .= "\n" . '$bb->wordpress_mu_primary_blog_id = ' . bp_get_root_blog_id() . ';'; 
  47.  
  48. if ( defined( 'AUTH_SALT' ) ) { 
  49. $file .= "\n\n" . 'define(\'BB_AUTH_SALT\', \'' . addslashes( AUTH_SALT ) . '\');'; 
  50.  
  51. if ( defined( 'LOGGED_IN_SALT' ) ) { 
  52. $file .= "\n" . 'define(\'BB_LOGGED_IN_SALT\', \'' . addslashes( LOGGED_IN_SALT ) . '\');'; 
  53.  
  54. if ( defined( 'SECURE_AUTH_SALT' ) ) { 
  55. $file .= "\n" . 'define(\'BB_SECURE_AUTH_SALT\', \'' . addslashes( SECURE_AUTH_SALT ) . '\');'; 
  56.  
  57. $file .= "\n\n" . 'define(\'WP_AUTH_COOKIE_VERSION\', 2);'; 
  58. $file .= "\n\n" . '?>'; 
  59.  
  60. if ( $initial_write == 1 ) { 
  61. $file_handle = fopen( $location, 'w' ); 
  62. fwrite( $file_handle, $file ); 
  63. fclose( $file_handle ); 
  64. } else { 
  65. $initial_write = $file; 
  66.  
  67. bp_update_option( 'bb-config-location', $location ); 
  68. return $initial_write;