[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-forums/bbpress/ -> bb-settings.php (source)

   1  <?php
   2  /**
   3   * Used to setup and fix common variables and include
   4   * the bbPress and BackPress procedural and class libraries.
   5   *
   6   * You should not have to change this file, all configuration
   7   * should be possible in bb-config.php
   8   *
   9   * @package bbPress
  10   */
  11  
  12  
  13  
  14  // Die if called directly
  15  if ( !defined( 'BB_PATH' ) ) {
  16      die( 'This file cannot be called directly.' );
  17  }
  18  
  19  // Set default timezone in PHP 5.
  20  if ( function_exists( 'date_default_timezone_set' ) )
  21          date_default_timezone_set( 'UTC' );
  22  
  23  /**
  24   * bb_unregister_GLOBALS() - Turn register globals off
  25   *
  26   * @access private
  27   * @return null Will return null if register_globals PHP directive was disabled
  28   */
  29  function bb_unregister_GLOBALS()
  30  {
  31      if ( !ini_get( 'register_globals' ) ) {
  32          return;
  33      }
  34  
  35      if ( isset($_REQUEST['GLOBALS']) ) {
  36          die( 'GLOBALS overwrite attempt detected' );
  37      }
  38  
  39      // Variables that shouldn't be unset
  40      $noUnset = array( 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'bb_table_prefix', 'bb' );
  41  
  42      $input = array_merge( $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset( $_SESSION ) && is_array( $_SESSION ) ? $_SESSION : array() );
  43      foreach ( $input as $k => $v ) {
  44          if ( !in_array( $k, $noUnset ) && isset( $GLOBALS[$k] ) ) {
  45              $GLOBALS[$k] = NULL;
  46              unset( $GLOBALS[$k] );
  47          }
  48      }
  49  }
  50  bb_unregister_GLOBALS();
  51  
  52  
  53  
  54  /**
  55   * Let bbPress know what we are up to at the moment
  56   */
  57  
  58  /**
  59   * Whether the current script is in the admin area or not
  60   */
  61  if ( !defined( 'BB_IS_ADMIN' ) ) {
  62      define( 'BB_IS_ADMIN', false );
  63  } elseif ( BB_IS_ADMIN ) {
  64      $bb_hardcoded = (array) $bb;
  65  }
  66  
  67  /**
  68   * Whether the current script is part of the installation process or not
  69   * @since 1.0
  70   */
  71  if ( !defined( 'BB_INSTALLING' ) ) {
  72      define( 'BB_INSTALLING', false );
  73  }
  74  
  75  /**
  76   * Whether to load deprecated routines, constants and functions
  77   * @since 1.0
  78   */
  79  if ( !defined( 'BB_LOAD_DEPRECATED' ) ) {
  80      define( 'BB_LOAD_DEPRECATED', true );
  81  }
  82  
  83  
  84  
  85  /**
  86   * Remove filters and action that have been set by an included WordPress install
  87   */
  88  if ( defined( 'ABSPATH' ) ) {
  89      $wp_filter = array();
  90      $wp_actions = array();
  91      $merged_filters = array();
  92      $wp_current_filter = array();
  93  }
  94  
  95  
  96  
  97  /**
  98   * Define include paths and load core BackPress libraries
  99   */
 100  
 101  /**
 102   * The full path to the BackPress libraries
 103   */
 104  if ( !defined( 'BACKPRESS_PATH' ) ) {
 105      define( 'BACKPRESS_PATH', BB_PATH . BB_INC . 'backpress/' );
 106  }
 107  
 108  // Load logging class
 109  require_once( BACKPRESS_PATH . 'class.bp-log.php' );
 110  $bb_log = new BP_Log();
 111  if ( defined( 'BB_LOG_LEVEL' ) ) {
 112      $bb_log->set_level( BB_LOG_LEVEL );
 113  }
 114  if ( defined( 'BB_LOG_TYPE' ) ) {
 115      $bb_log->set_type( BB_LOG_TYPE );
 116  }
 117  if ( defined( 'BB_LOG_FILENAME' ) ) {
 118      $bb_log->set_filename( BB_LOG_FILENAME );
 119  }
 120  $bb_log->notice('Logging started');
 121  
 122  // Load core BackPress functions
 123  require_once( BACKPRESS_PATH . 'functions.core.php' );
 124  require_once( BACKPRESS_PATH . 'functions.compat.php' );
 125  require_once( BACKPRESS_PATH . 'functions.formatting.php' );
 126  
 127  // WP_Error
 128  if ( !class_exists( 'WP_Error' ) ) {
 129      require_once( BACKPRESS_PATH . 'class.wp-error.php' );
 130  }
 131  
 132  
 133  
 134  /**
 135   * Set up database parameters based on config and initialise
 136   */
 137  
 138  /**
 139   * Define the full path to the database class
 140   */
 141  if ( !defined( 'BB_DATABASE_CLASS_INCLUDE' ) ) {
 142      define( 'BB_DATABASE_CLASS_INCLUDE', BACKPRESS_PATH . 'class.bpdb-multi.php' );
 143  }
 144  
 145  /**
 146   * Define the name of the database class
 147   */
 148  if ( !defined( 'BB_DATABASE_CLASS' ) ) {
 149      define( 'BB_DATABASE_CLASS', 'BPDB_Multi' );
 150  }
 151  
 152  if ( in_array( BB_DATABASE_CLASS, array( 'BPDB', 'BPDB_Multi' ) ) ) {
 153      /**
 154       * Define BackPress Database errors if not already done - no localisation at this stage
 155       */
 156      if ( !defined( 'BPDB__CONNECT_ERROR_MESSAGE' ) ) {
 157          define( 'BPDB__CONNECT_ERROR_MESSAGE', 'ERROR: Could not establish a database connection' );
 158      }
 159      if ( !defined( 'BPDB__CONNECT_ERROR_MESSAGE' ) ) {
 160          define( 'BPDB__SELECT_ERROR_MESSAGE', 'ERROR: Can\'t select database.' );
 161      }
 162      if ( !defined( 'BPDB__ERROR_STRING' ) ) {
 163          define( 'BPDB__ERROR_STRING', 'ERROR: bbPress database error - "%s" for query "%s" via caller "%s"' );
 164      }
 165      if ( !defined( 'BPDB__ERROR_HTML' ) ) {
 166          define( 'BPDB__ERROR_HTML', '<div id="error"><p class="bpdberror"><strong>Database error:</strong> [%s]<br /><code>%s</code><br />Caller: %s</p></div>' );
 167      }
 168      if ( !defined( 'BPDB__DB_VERSION_ERROR' ) ) {
 169          define( 'BPDB__DB_VERSION_ERROR', 'ERROR: bbPress requires MySQL 4.0.0 or higher' );
 170      }
 171      if ( !defined( 'BPDB__PHP_EXTENSION_MISSING' ) ) {
 172          define( 'BPDB__PHP_EXTENSION_MISSING', 'ERROR: bbPress requires The MySQL PHP extension' );
 173      }
 174  }
 175  
 176  // Load the database class
 177  if ( BB_DATABASE_CLASS_INCLUDE ) {
 178      require_once( BB_DATABASE_CLASS_INCLUDE );
 179  }
 180  
 181  // Die if there is no database table prefix
 182  if ( !$bb_table_prefix ) {
 183      die( 'You must specify a table prefix in your <code>bb-config.php</code> file.' );
 184  }
 185  
 186  // Setup the global database connection
 187  $bbdb_class = BB_DATABASE_CLASS;
 188  $bbdb = new $bbdb_class( array(
 189      'name' => BBDB_NAME,
 190      'user' => BBDB_USER,
 191      'password' => BBDB_PASSWORD,
 192      'host' => BBDB_HOST,
 193      'charset' => defined( 'BBDB_CHARSET' ) ? BBDB_CHARSET : false,
 194      'collate' => defined( 'BBDB_COLLATE' ) ? BBDB_COLLATE : false
 195  ) );
 196  unset( $bbdb_class );
 197  
 198  /**
 199   * bbPress tables
 200   */
 201  $bbdb->tables = array(
 202      'forums'             => false,
 203      'meta'               => false,
 204      'posts'              => false,
 205      'tagged'             => false, // Deprecated
 206      'tags'               => false, // Deprecated
 207      'terms'              => false,
 208      'term_relationships' => false,
 209      'term_taxonomy'      => false,
 210      'topics'             => false,
 211      'topicmeta'          => false, // Deprecated
 212      'users'              => false,
 213      'usermeta'           => false
 214  );
 215  
 216  // Set the prefix on the tables
 217  if ( is_wp_error( $bbdb->set_prefix( $bb_table_prefix ) ) ) {
 218      die( 'Your table prefix may only contain letters, numbers and underscores.' );
 219  }
 220  
 221  // Set a site id if there isn't one already
 222  if ( !isset( $bb->site_id ) ) {
 223      $bb->site_id = 1;
 224  }
 225  
 226  
 227  
 228  /**
 229   * Load core bbPress libraries
 230   */
 231  
 232  require_once( BB_PATH . BB_INC . 'functions.bb-core.php' );
 233  require_once( BB_PATH . BB_INC . 'functions.bb-forums.php' );
 234  require_once( BB_PATH . BB_INC . 'functions.bb-topics.php' );
 235  require_once( BB_PATH . BB_INC . 'functions.bb-posts.php' );
 236  require_once( BB_PATH . BB_INC . 'functions.bb-topic-tags.php' );
 237  require_once( BB_PATH . BB_INC . 'functions.bb-users.php' );
 238  require_once( BB_PATH . BB_INC . 'functions.bb-meta.php' );
 239  require_once( BB_PATH . BB_INC . 'class.bb-query.php' );
 240  require_once( BB_PATH . BB_INC . 'class.bb-walker.php' );
 241  
 242  
 243  
 244  /**
 245   * Load API and object handling BackPress libraries
 246   */
 247  
 248  // Plugin API
 249  if ( !function_exists( 'add_filter' ) ) {
 250      require_once( BACKPRESS_PATH . 'functions.plugin-api.php' );
 251  }
 252  
 253  // Shortcodes API
 254  if ( !function_exists( 'add_shortcode' ) ) {
 255      require_once( BACKPRESS_PATH . 'functions.shortcodes.php' );
 256  } else {
 257      remove_all_shortcodes();
 258  }
 259  
 260  
 261  
 262  /**
 263   * Define the full path to the object cache functions include
 264   */
 265  $_internal_object_cache_functions_include = BACKPRESS_PATH . 'loader.wp-object-cache.php';
 266  $_memcached_object_cache_functions_include = BACKPRESS_PATH . 'loader.wp-object-cache-memcached.php';
 267  if ( !defined( 'BB_OBJECT_CACHE_FUNCTIONS_INCLUDE' ) ) {
 268      if ( defined( 'BB_OBJECT_CACHE_TYPE' ) && 'memcached' === BB_OBJECT_CACHE_TYPE ) {
 269          define( 'BB_OBJECT_CACHE_FUNCTIONS_INCLUDE', $_memcached_object_cache_functions_include );
 270      } else {
 271          define( 'BB_OBJECT_CACHE_FUNCTIONS_INCLUDE', $_internal_object_cache_functions_include );
 272      }
 273  }
 274  
 275  // See if a caching class is already loaded (by WordPress)
 276  if ( function_exists( 'wp_cache_init' ) ) {
 277      if ( isset( $_wp_using_ext_object_cache ) ) {
 278          $_bb_using_ext_object_cache = $_wp_using_ext_object_cache;
 279      } else {
 280          $_bb_using_ext_object_cache = false;
 281      }
 282  } elseif ( BB_OBJECT_CACHE_FUNCTIONS_INCLUDE ) {
 283      // Load the object cache class
 284      require_once( BB_OBJECT_CACHE_FUNCTIONS_INCLUDE );
 285      if ( BB_OBJECT_CACHE_FUNCTIONS_INCLUDE === $_internal_object_cache_functions_include ) {
 286          $_bb_using_ext_object_cache = false;
 287      } else {
 288          $_bb_using_ext_object_cache = true;
 289      }
 290  }
 291  unset( $_internal_object_cache_functions_include );
 292  
 293  // Instantiate the $wp_object_cache object using wp_cache_init()
 294  if ( function_exists( 'wp_cache_init' ) ) {
 295      // Clear WordPress cache if it exists already - maybe should save and re-load?
 296      unset( $wp_object_cache );
 297      wp_cache_init();
 298      if ( function_exists( 'wp_cache_add_global_groups' ) ) {
 299          wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'useremail', 'usernicename' ) );
 300      }
 301  }
 302  
 303  
 304  
 305  /**
 306   * Load mapping class for BackPress to store options
 307   */
 308  require_once( BB_PATH . BB_INC . 'class.bp-options.php' );
 309  require_once( BACKPRESS_PATH . 'functions.bp-options.php' );
 310  
 311  
 312  
 313  /**
 314   * Load WP_Http class
 315   */
 316  if ( !class_exists( 'WP_Http' ) ) {
 317      require_once( BACKPRESS_PATH . 'class.wp-http.php' );
 318  }
 319  
 320  
 321  
 322  /**
 323   * Determine language settings and load i10n libraries as required
 324   */
 325  
 326  /**
 327   * The full path to the directory containing language files
 328   */
 329  if ( !defined( 'BB_LANG_DIR' ) ) {
 330      if ( BB_LOAD_DEPRECATED && defined( 'BBLANGDIR' ) ) {
 331          // User has set old constant
 332          bb_log_deprecated( 'constant', 'BBLANGDIR', 'BB_LANG_DIR' );
 333          define( 'BB_LANG_DIR', BBLANGDIR );
 334      } else {
 335          define( 'BB_LANG_DIR', BB_PATH . 'my-languages/' ); // absolute path with trailing slash
 336      }
 337  }
 338  
 339  /**
 340   * The language in which to display bbPress
 341   */
 342  if ( BB_LOAD_DEPRECATED && !defined( 'BB_LANG' ) && defined( 'BBLANG' ) && '' != BBLANG ) {
 343      // User has set old constant
 344      bb_log_deprecated( 'constant', 'BBLANG', 'BB_LANG' );
 345      define( 'BB_LANG', BBLANG );
 346  }
 347  if ( !class_exists( 'MO' ) ) {
 348      require_once( BACKPRESS_PATH . 'pomo/mo.php' );
 349  }
 350  
 351  // Is WordPress loaded
 352  if ( !defined( 'BB_IS_WP_LOADED') ) {
 353      define( 'BB_IS_WP_LOADED', defined( 'DB_NAME' ) );
 354  }
 355  
 356  // Only load this if WordPress isn't loaded
 357  if ( !BB_IS_WP_LOADED ) {
 358      require_once( BACKPRESS_PATH . 'functions.kses.php' );
 359  }
 360  require_once( BB_PATH . BB_INC . 'functions.bb-l10n.php' );
 361  
 362  
 363  
 364  /**
 365   * Routines related to installation
 366   */
 367  
 368  // Load BB_CHANNELS_INCLUDE if it exists, must be done before the install is completed
 369  if ( defined( 'BB_CHANNELS_INCLUDE' ) && file_exists( BB_CHANNELS_INCLUDE ) && !is_dir( BB_CHANNELS_INCLUDE ) ) {
 370      require_once( BB_CHANNELS_INCLUDE );
 371  }
 372  
 373  // If there is no forum table in the database then redirect to the installer
 374  if ( !BB_INSTALLING && !bb_is_installed() ) {
 375      $link = preg_replace( '|(/bb-admin)?/[^/]+?$|', '/', $_SERVER['PHP_SELF'] ) . 'bb-admin/install.php';
 376      require_once( BB_PATH . BB_INC . 'functions.bb-pluggable.php' );
 377      wp_redirect( $link );
 378      die();
 379  }
 380  
 381  // Setup some variables in the $bb class if they don't exist - some of these are deprecated
 382  if ( BB_LOAD_DEPRECATED ) {
 383      foreach ( array( 'use_cache' => false, 'debug' => false ) as $o => $oo ) {
 384          if ( !isset( $bb->$o ) ) {
 385              $bb->$o = $oo;
 386          } else {
 387              bb_log_deprecated( 'variable', '$bb->' . $o );
 388          }
 389      }
 390      unset( $o, $oo );
 391  }
 392  
 393  // Disable plugins during installation
 394  if ( BB_INSTALLING ) {
 395      foreach ( array('active_plugins') as $i ) {
 396          $bb->$i = false;
 397      }
 398      unset( $i );
 399  }
 400  
 401  
 402  
 403  /**
 404   * Load additional bbPress libraries
 405   */
 406  
 407  require_once( BB_PATH . BB_INC . 'functions.bb-formatting.php' );
 408  require_once( BB_PATH . BB_INC . 'functions.bb-template.php' );
 409  require_once( BB_PATH . BB_INC . 'functions.bb-capabilities.php' );
 410  require_once( BB_PATH . BB_INC . 'class.bb-pingbacks.php' );
 411  
 412  
 413  
 414  // Cache options from the database
 415  if ( !isset( $bb->load_options ) ) {
 416      $bb->load_options = true;
 417  }
 418  if ( $bb->load_options ) {
 419      $bbdb->suppress_errors();
 420      bb_cache_all_options();
 421      $bbdb->suppress_errors( false );
 422  }
 423  
 424  /**
 425   * Set the URI and derivitaves
 426   */
 427  if ( $bb->uri = bb_get_option( 'uri' ) ) {
 428      $bb->uri = rtrim( trim( $bb->uri ), " \t\n\r\0\x0B/" ) . '/';
 429      
 430      if ( preg_match( '@^(https?://[^/]+)((?:/.*)*/{1,1})$@i', $bb->uri, $matches ) ) {
 431          // Used when setting up cookie domain
 432          $bb->domain = $matches[1];
 433          // Used when setting up cookie paths
 434          $bb->path = $matches[2];
 435      }
 436      unset( $matches );
 437  } elseif ( BB_LOAD_DEPRECATED ) {
 438      // Backwards compatibility
 439      // These were never set in the database
 440      if ( isset( $bb->domain ) ) {
 441          bb_log_deprecated( 'variable', '$bb->domain', '$bb->uri' );
 442          $bb->domain = rtrim( trim( $bb->domain ), " \t\n\r\0\x0B/" );
 443      }
 444      if ( isset( $bb->path ) ) {
 445          bb_log_deprecated( 'variable', '$bb->path', '$bb->uri' );
 446          $bb->path = trim( $bb->path );
 447          if ( $bb->path != '/' ) $bb->path = '/' . trim( $bb->path, " \t\n\r\0\x0B/" ) . '/';
 448      }
 449      // We need both to build a uri
 450      if ( $bb->domain && $bb->path ) {
 451          $bb->uri = $bb->domain . $bb->path;
 452      }
 453  }
 454  
 455  // Die if no URI
 456  if ( !BB_INSTALLING && !$bb->uri ) {
 457      bb_die( __( 'Could not determine site URI' ) );
 458  }
 459  
 460  /**
 461   * BB_FORCE_SSL_USER_FORMS - Whether to force use of ssl on user forms like login, registration and profile editing
 462   */
 463  if ( !defined( 'BB_FORCE_SSL_USER_FORMS' ) ) {
 464      define( 'BB_FORCE_SSL_USER_FORMS', false );
 465  }
 466  force_ssl_login( BB_FORCE_SSL_USER_FORMS );
 467  
 468  /**
 469   * BB_FORCE_SSL_ADMIN - Whether to force use of ssl in the admin area
 470   */
 471  if ( !defined( 'BB_FORCE_SSL_ADMIN' ) ) {
 472      define( 'BB_FORCE_SSL_ADMIN', false );
 473  }
 474  force_ssl_admin( BB_FORCE_SSL_ADMIN );
 475  
 476  // Load default filters
 477  require_once( BB_PATH . BB_INC . 'defaults.bb-filters.php' );
 478  
 479  // Load default scripts
 480  require_once( BB_PATH . BB_INC . 'functions.bb-script-loader.php' );
 481  
 482  /* Check if the globals have been sanitized by WordPress or not (else there would be extra slashes while deep integration) */
 483  if ( !function_exists( 'wp_magic_quotes' ) ) {
 484      // Sanitise external input
 485      $_GET    = bb_global_sanitize( $_GET );
 486      $_POST   = bb_global_sanitize( $_POST );
 487      $_COOKIE = bb_global_sanitize( $_COOKIE, false );
 488      $_SERVER = bb_global_sanitize( $_SERVER );
 489  }
 490  
 491  
 492  /**
 493   * Define theme and plugin constants
 494   */
 495  
 496  /**
 497   * Full path to the location of the core plugins directory
 498   */
 499  define( 'BB_CORE_PLUGIN_DIR', BB_PATH . 'bb-plugins/' );
 500  
 501  /**
 502   * Full URL of the core plugins directory
 503   */
 504  define( 'BB_CORE_PLUGIN_URL', $bb->uri . 'bb-plugins/' );
 505  
 506  /**
 507   * Full path to the location of the core themes directory
 508   */
 509  define( 'BB_CORE_THEME_DIR', BB_PATH . 'bb-templates/' );
 510  
 511  /**
 512   * Full URL of the core themes directory
 513   */
 514  define( 'BB_CORE_THEME_URL', $bb->uri . 'bb-templates/' );
 515  
 516  /**
 517   * The default theme
 518   */
 519  define( 'BB_DEFAULT_THEME', 'core#kakumei' );
 520  
 521  /**
 522   * Full path to the location of the default theme directory
 523   */
 524  define( 'BB_DEFAULT_THEME_DIR', BB_CORE_THEME_DIR . 'kakumei/' );
 525  
 526  /**
 527   * Full URL of the default theme directory
 528   */
 529  define( 'BB_DEFAULT_THEME_URL', BB_CORE_THEME_URL . 'kakumei/' );
 530  
 531  /**
 532   * Full path to the location of the user plugins directory
 533   */
 534  if ( !defined( 'BB_PLUGIN_DIR' ) ) {
 535      if ( BB_LOAD_DEPRECATED && defined( 'BBPLUGINDIR' ) ) {
 536          // User has set old constant
 537          bb_log_deprecated( 'constant', 'BBPLUGINDIR', 'BB_PLUGIN_DIR' );
 538          define( 'BB_PLUGIN_DIR', BBPLUGINDIR );
 539      } else {
 540          define( 'BB_PLUGIN_DIR', BB_PATH . 'my-plugins/' );
 541      }
 542  }
 543  
 544  /**
 545   * Full URL of the user plugins directory
 546   */
 547  if ( !defined( 'BB_PLUGIN_URL' ) ) {
 548      if ( BB_LOAD_DEPRECATED && defined( 'BBPLUGINURL' ) ) {
 549          // User has set old constant
 550          bb_log_deprecated( 'constant', 'BBPLUGINURL', 'BB_PLUGIN_URL' );
 551          define( 'BB_PLUGIN_URL', BBPLUGINURL );
 552      } else {
 553          define( 'BB_PLUGIN_URL', $bb->uri . 'my-plugins/' );
 554      }
 555  }
 556  
 557  /**
 558   * Full path to the location of the user themes directory
 559   */
 560  if ( !defined( 'BB_THEME_DIR' ) ) {
 561      if ( BB_LOAD_DEPRECATED && defined( 'BBTHEMEDIR' ) ) {
 562          // User has set old constant
 563          bb_log_deprecated( 'constant', 'BBTHEMEDIR', 'BB_THEME_DIR' );
 564          define( 'BB_THEME_DIR', BBTHEMEDIR );
 565      } else {
 566          define( 'BB_THEME_DIR', BB_PATH . 'my-templates/' );
 567      }
 568  }
 569  
 570  /**
 571   * Full URL of the user themes directory
 572   */
 573  if ( !defined( 'BB_THEME_URL' ) ) {
 574      if ( BB_LOAD_DEPRECATED && defined( 'BBTHEMEURL' ) ) {
 575          // User has set old constant
 576          bb_log_deprecated( 'constant', 'BBTHEMEURL', 'BB_THEME_URL' );
 577          define( 'BB_THEME_URL', BBTHEMEURL );
 578      } else {
 579          define( 'BB_THEME_URL', $bb->uri . 'my-templates/' );
 580      }
 581  }
 582  
 583  /**
 584   * Look-up arrays provide easier access to arbitrary plugin and theme locations
 585   */
 586  $_default_plugin_locations = array(
 587      'core' => array(
 588          'dir' => BB_CORE_PLUGIN_DIR,
 589          'url' => BB_CORE_PLUGIN_URL,
 590          'cap' => 'manage_plugins'
 591      ),
 592      'user' => array(
 593          'dir' => BB_PLUGIN_DIR,
 594          'url' => BB_PLUGIN_URL,
 595          'cap' => 'manage_plugins'
 596      )
 597  );
 598  
 599  if ( isset( $bb->plugin_locations ) && is_array( $bb->plugin_locations ) ) {
 600      $bb->plugin_locations = array_merge( $_default_plugin_locations, $bb->plugin_locations );
 601  } else {
 602      $bb->plugin_locations = $_default_plugin_locations;
 603  }
 604  
 605  // Don't accept a plugin location called "all". Unlikely, but really not desirable.
 606  if ( isset( $bb->plugin_locations['all'] ) ) {
 607      unset( $bb->plugin_locations['all'] );
 608  }
 609  
 610  $_default_theme_locations = array(
 611      'core' => array(
 612          'dir' => BB_CORE_THEME_DIR,
 613          'url' => BB_CORE_THEME_URL,
 614          'cap' => 'manage_themes'
 615      ),
 616      'user' => array(
 617          'dir' => BB_THEME_DIR,
 618          'url' => BB_THEME_URL,
 619          'cap' => 'manage_themes'
 620      )
 621  );
 622  
 623  if ( isset( $bb->theme_locations ) && is_array( $bb->theme_locations ) ) {
 624      $bb->theme_locations = array_merge( $_default_theme_locations, $bb->theme_locations );
 625  } else {
 626      $bb->theme_locations = $_default_theme_locations;
 627  }
 628  
 629  
 630  
 631  /**
 632   * Add custom tables if present
 633   */
 634  
 635  // Resolve the various ways custom user tables might be setup
 636  bb_set_custom_user_tables();
 637  
 638  // Add custom databases if required
 639  if ( isset( $bb->custom_databases ) ) {
 640      foreach ( $bb->custom_databases as $connection => $database ) {
 641          $bbdb->add_db_server( $connection, $database );
 642      }
 643  }
 644  unset( $connection, $database );
 645  
 646  // Add custom tables if required
 647  if ( isset( $bb->custom_tables ) ) {
 648      $bbdb->tables = array_merge( $bbdb->tables, $bb->custom_tables );
 649      if ( is_wp_error( $bbdb->set_prefix( $bbdb->prefix ) ) ) {
 650          die( __( 'Your user table prefix may only contain letters, numbers and underscores.' ) );
 651      }
 652  }
 653  
 654  
 655  
 656  /**
 657   * Sort out cookies so they work with WordPress (if required)
 658   * Note that database integration is no longer a pre-requisite for cookie integration
 659   */
 660  
 661  $bb->wp_siteurl = bb_get_option( 'wp_siteurl' );
 662  if ( $bb->wp_siteurl ) {
 663      $bb->wp_siteurl = rtrim( trim( $bb->wp_siteurl ), " \t\n\r\0\x0B/" );
 664  }
 665  
 666  $bb->wp_home = bb_get_option( 'wp_home' );
 667  if ( $bb->wp_home ) {
 668      $bb->wp_home = rtrim( trim( $bb->wp_home ), " \t\n\r\0\x0B/" );
 669  }
 670  
 671  $bb->wp_cookies_integrated = false;
 672  $bb->cookiedomain = bb_get_option( 'cookiedomain' );
 673  $bb->cookiepath = bb_get_option( 'cookiepath' );
 674  $bb->wordpress_mu_primary_blog_id = bb_get_option( 'wordpress_mu_primary_blog_id' );
 675  
 676  if ( $bb->wp_siteurl && $bb->wp_home ) {
 677      if ( $bb->cookiedomain ) {
 678          $bb->wp_cookies_integrated = true;
 679      } else {
 680          $cookiedomain = bb_get_common_domains( $bb->uri, $bb->wp_home );
 681          if ( bb_match_domains( $bb->uri, $bb->wp_home ) ) {
 682              if ( $bb->wordpress_mu_primary_blog_id ) {
 683                  $bb->cookiedomain = '.' . $cookiedomain;
 684              }
 685              if ( !$bb->cookiepath ) {
 686                  $bb->cookiepath = bb_get_common_paths( $bb->uri, $bb->wp_home );
 687              }
 688              $bb->wp_cookies_integrated = true;
 689          } elseif ( $cookiedomain && strpos( $cookiedomain, '.' ) !== false ) {
 690              $bb->cookiedomain = '.' . $cookiedomain;
 691              if ( !$bb->cookiepath ) {
 692                  $bb->cookiepath = bb_get_common_paths( $bb->uri, $bb->wp_home );
 693              }
 694              $bb->wp_cookies_integrated = true;
 695          }
 696          unset( $cookiedomain );
 697      }
 698  }
 699  
 700  define( 'BB_HASH', $bb->wp_cookies_integrated ? md5( $bb->wp_siteurl ) : md5( $bb->uri ) );
 701  
 702  if ( BB_LOAD_DEPRECATED ) {
 703      // Deprecated setting
 704      $bb->usercookie = bb_get_option( 'usercookie' );
 705      if ( !$bb->usercookie ) {
 706          $bb->usercookie = ( $bb->wp_cookies_integrated ? 'wordpressuser_' : 'bb_user_' ) . BB_HASH;
 707      } else {
 708          bb_log_deprecated( 'variable', '$bb->usercookie' );
 709      }
 710  
 711      // Deprecated setting
 712      $bb->passcookie = bb_get_option( 'passcookie' );
 713      if ( !$bb->passcookie ) {
 714          $bb->passcookie = ( $bb->wp_cookies_integrated ? 'wordpresspass_' : 'bb_pass_' ) . BB_HASH;
 715      } else {
 716          bb_log_deprecated( 'variable', '$bb->passcookie' );
 717      }
 718  }
 719  
 720  $bb->authcookie = bb_get_option( 'authcookie' );
 721  if ( !$bb->authcookie ) {
 722      $bb->authcookie = ( $bb->wp_cookies_integrated ? 'wordpress_' : 'bbpress_' ) . BB_HASH;
 723  }
 724  
 725  $bb->secure_auth_cookie = bb_get_option( 'secure_auth_cookie' );
 726  if ( !$bb->secure_auth_cookie ) {
 727      $bb->secure_auth_cookie = ( $bb->wp_cookies_integrated ? 'wordpress_sec_' : 'bbpress_sec_' ) . BB_HASH;
 728  }
 729  
 730  $bb->logged_in_cookie = bb_get_option( 'logged_in_cookie' );
 731  if ( !$bb->logged_in_cookie ) {
 732      $bb->logged_in_cookie = ( $bb->wp_cookies_integrated ? 'wordpress_logged_in_' : 'bbpress_logged_in_' ) . BB_HASH;
 733  }
 734  
 735  // Cookie path was set before integration logic above
 736  if ( !$bb->cookiepath ) {
 737      $bb->cookiepath = $bb->wp_cookies_integrated ? preg_replace( '|https?://[^/]+|i', '', $bb->wp_home ) : $bb->path;
 738  }
 739  $bb->cookiepath = rtrim( trim( $bb->cookiepath ), " \t\n\r\0\x0B/" ) . '/';
 740  
 741  $bb->admin_cookie_path = bb_get_option( 'admin_cookie_path' );
 742  if ( !$bb->admin_cookie_path ) {
 743      $bb->admin_cookie_path = $bb->path . 'bb-admin';
 744  }
 745  if ( '/' !== $bb->admin_cookie_path = trim( $bb->admin_cookie_path ) ) {
 746      $bb->admin_cookie_path = rtrim( $bb->admin_cookie_path, " \t\n\r\0\x0B/" );
 747  }
 748  
 749  if ( BB_LOAD_DEPRECATED ) {
 750      $_plugin_cookie_paths = bb_get_option( 'plugin_cookie_paths' );
 751  
 752      // Deprecated settings
 753      if ( $_plugin_cookie_paths ) {
 754          if ( isset( $_plugin_cookie_paths['core'] ) && $_plugin_cookie_paths['core'] ) {
 755              $bb->core_plugins_cookie_path = $_plugin_cookie_paths['core'];
 756          }
 757          if ( isset( $_plugin_cookie_paths['user'] ) && $_plugin_cookie_paths['user'] ) {
 758              $bb->user_plugins_cookie_path = $_plugin_cookie_paths['user'];
 759          }
 760      } else {
 761          if ( $bb->core_plugins_cookie_path = bb_get_option( 'core_plugins_cookie_path' ) ) {
 762              bb_log_deprecated( 'variable', '$bb->core_plugins_cookie_path', '$bb->plugin_cookie_paths[\'core\']' );
 763          }
 764          if ( $bb->user_plugins_cookie_path = bb_get_option( 'user_plugins_cookie_path' ) ) {
 765              bb_log_deprecated( 'variable', '$bb->core_plugins_cookie_path', '$bb->plugin_cookie_paths[\'user\']' );
 766          }
 767      }
 768  
 769      if ( !$bb->core_plugins_cookie_path && isset( $bb->plugin_locations['core']['url'] ) && $bb->plugin_locations['core']['url'] ) {
 770          $bb->core_plugins_cookie_path = preg_replace( '|https?://[^/]+|i', '', $bb->plugin_locations['core']['url'] );
 771      }
 772      $bb->core_plugins_cookie_path = rtrim( trim( $bb->core_plugins_cookie_path ), " \t\n\r\0\x0B/" );
 773  
 774      if ( !$bb->user_plugins_cookie_path && isset( $bb->plugin_locations['user']['url'] ) && $bb->plugin_locations['user']['url'] ) {
 775          $bb->user_plugins_cookie_path = preg_replace( '|https?://[^/]+|i', '', $bb->plugin_locations['user']['url'] );
 776      }
 777      $bb->user_plugins_cookie_path = rtrim( trim( $bb->user_plugins_cookie_path ), " \t\n\r\0\x0B/" );
 778  
 779      if ( !$_plugin_cookie_paths ) {
 780          $bb->plugin_cookie_paths = array();
 781      }
 782      if ( !isset( $_plugin_cookie_paths['core'] ) ) {
 783          $bb->plugin_cookie_paths['core'] = $bb->core_plugins_cookie_path;
 784      }
 785      if ( !isset( $_plugin_cookie_paths['user'] ) ) {
 786          $bb->plugin_cookie_paths['user'] = $bb->user_plugins_cookie_path;
 787      }
 788  }
 789  
 790  $bb->sitecookiepath = bb_get_option( 'sitecookiepath' );
 791  $_bb_sitecookiepath = $bb->sitecookiepath;
 792  if ( !$bb->sitecookiepath && $bb->wp_cookies_integrated ) {
 793      $bb->sitecookiepath = preg_replace( '|https?://[^/]+|i', '', $bb->wp_siteurl );
 794      $_bb_sitecookiepath = $bb->sitecookiepath;
 795  }
 796  $bb->sitecookiepath = rtrim( trim( $bb->sitecookiepath ), " \t\n\r\0\x0B/" ) . '/';
 797  
 798  $bb->wp_admin_cookie_path = bb_get_option( 'wp_admin_cookie_path' );
 799  if ( !$bb->wp_admin_cookie_path && $bb->wp_cookies_integrated ) {
 800      if ( $bb->wordpress_mu_primary_blog_id ) {
 801          $bb->wp_admin_cookie_path = $_bb_sitecookiepath;
 802      } else {
 803          $bb->wp_admin_cookie_path = $_bb_sitecookiepath . '/wp-admin';
 804      }
 805  }
 806  if ( '/' !== $bb->wp_admin_cookie_path = trim( $bb->wp_admin_cookie_path ) ) {
 807      $bb->wp_admin_cookie_path = rtrim( $bb->wp_admin_cookie_path, " \t\n\r\0\x0B/" );
 808  }
 809  
 810  $bb->wp_plugins_cookie_path = bb_get_option( 'wp_plugins_cookie_path' );
 811  if ( !$bb->wp_plugins_cookie_path && $bb->wp_cookies_integrated ) {
 812      // This is a best guess only, should be manually set to match WP_PLUGIN_URL
 813      $bb->wp_plugins_cookie_path = $_bb_sitecookiepath . '/wp-content/plugins';
 814  }
 815  if ( '/' !== $bb->wp_plugins_cookie_path = trim( $bb->wp_plugins_cookie_path ) ) {
 816      $bb->wp_plugins_cookie_path = rtrim( $bb->wp_plugins_cookie_path, " \t\n\r\0\x0B/" );
 817  }
 818  unset( $_bb_sitecookiepath );
 819  
 820  /**
 821   * Should be exactly the same as the default value of the KEYS in bb-config-sample.php
 822   * @since 1.0
 823   */
 824  $bb_default_secret_key = 'put your unique phrase here';
 825  
 826  
 827  
 828  /**
 829   * Initialise localisation
 830   */
 831  
 832  // Load the default text localization domain.
 833  bb_load_default_textdomain();
 834  
 835  // Pull in locale data after loading text domain.
 836  require_once( BB_PATH . BB_INC . 'class.bb-locale.php' );
 837  
 838  /**
 839   * Localisation object
 840   */
 841  $bb_locale = new BB_Locale();
 842  
 843  
 844  
 845  /**
 846   * Remaining BackPress
 847   */
 848  
 849  // WP_Pass
 850  if ( !class_exists( 'WP_Pass' ) ) {
 851      require_once( BACKPRESS_PATH . 'class.wp-pass.php' );
 852  }
 853  
 854  // WP_Users
 855  if ( !class_exists( 'WP_Users' ) ) {
 856      require_once( BACKPRESS_PATH . 'class.wp-users.php' );
 857      $wp_users_object = new WP_Users( $bbdb );
 858  }
 859  
 860  if ( !class_exists( 'BP_Roles' ) ) {
 861      require_once( BACKPRESS_PATH . 'class.bp-roles.php' );
 862  }
 863  
 864  /**
 865   * BP_Roles object
 866   */
 867  $wp_roles = new BP_Roles( $bbdb );
 868  
 869  // BP_User
 870  if ( !class_exists( 'BP_User' ) ) {
 871      require_once( BACKPRESS_PATH . 'class.bp-user.php' );
 872  }
 873  
 874  // WP_Auth
 875  if ( !class_exists( 'WP_Auth' ) ) {
 876      require_once( BACKPRESS_PATH . 'class.wp-auth.php' );
 877  
 878      $cookies = array();
 879  
 880      $cookies['logged_in'][] = array(
 881          'domain' => $bb->cookiedomain,
 882          'path' => $bb->cookiepath,
 883          'name' => $bb->logged_in_cookie
 884      );
 885  
 886      if ( $bb->sitecookiepath && $bb->cookiepath != $bb->sitecookiepath ) {
 887          $cookies['logged_in'][] = array(
 888              'domain' => $bb->cookiedomain,
 889              'path' => $bb->sitecookiepath,
 890              'name' => $bb->logged_in_cookie
 891          );
 892      }
 893  
 894      $cookies['auth'][] = array(
 895          'domain' => $bb->cookiedomain,
 896          'path' => $bb->admin_cookie_path,
 897          'name' => $bb->authcookie
 898      );
 899  
 900      $cookies['secure_auth'][] = array(
 901          'domain' => $bb->cookiedomain,
 902          'path' => $bb->admin_cookie_path,
 903          'name' => $bb->secure_auth_cookie,
 904          'secure' => true
 905      );
 906  
 907      $_plugin_cookie_paths = bb_get_option( 'plugin_cookie_paths' );
 908      foreach ( $bb->plugin_locations as $_name => $_data ) {
 909          if ( isset( $_data['cookie_path'] ) && !empty( $_data['cookie_path'] ) ) {
 910              $_cookie_path = $_data['cookie_path'];
 911          } elseif ( !$_plugin_cookie_paths || !isset( $_plugin_cookie_paths[$_name] ) || !$_plugin_cookie_paths[$_name] ) {
 912              $_cookie_path = preg_replace( '|https?://[^/]+|i', '', $_data['url'] );
 913          } else {
 914              $_cookie_path = $_plugin_cookie_paths[$_name];
 915          }
 916          if ( '/' !== $_cookie_path = trim( $_cookie_path ) ) {
 917              $_cookie_path = rtrim( $_cookie_path, " \t\n\r\0\x0B/" );
 918          }
 919  
 920          if ( !$_cookie_path ) {
 921              continue;
 922          }
 923  
 924          $_auth = array(
 925              'domain' => $bb->cookiedomain,
 926              'path' => $_cookie_path,
 927              'name' => $bb->authcookie
 928          );
 929  
 930          if ( !in_array( $_auth, $cookies['auth'] ) ) {
 931              $cookies['auth'][] = $_auth;
 932          }
 933  
 934          $_secure_auth = array(
 935              'domain' => $bb->cookiedomain,
 936              'path' => $_cookie_path,
 937              'name' => $bb->secure_auth_cookie,
 938              'secure' => true
 939          );
 940  
 941          if ( !in_array( $_secure_auth, $cookies['secure_auth'] ) ) {
 942              $cookies['secure_auth'][] = $_secure_auth;
 943          }
 944      }
 945      unset( $_plugin_cookie_paths, $_type, $_data, $_cookie_path, $_auth, $_secure_auth );
 946  
 947      if ( $bb->wp_admin_cookie_path ) {
 948          $cookies['auth'][] = array(
 949              'domain' => $bb->cookiedomain,
 950              'path' => $bb->wp_admin_cookie_path,
 951              'name' => $bb->authcookie
 952          );
 953  
 954          $cookies['secure_auth'][] = array(
 955              'domain' => $bb->cookiedomain,
 956              'path' => $bb->wp_admin_cookie_path,
 957              'name' => $bb->secure_auth_cookie,
 958              'secure' => true
 959          );
 960      }
 961  
 962      if ( $bb->wp_plugins_cookie_path ) {
 963          $cookies['auth'][] = array(
 964              'domain' => $bb->cookiedomain,
 965              'path' => $bb->wp_plugins_cookie_path,
 966              'name' => $bb->authcookie
 967          );
 968  
 969          $cookies['secure_auth'][] = array(
 970              'domain' => $bb->cookiedomain,
 971              'path' => $bb->wp_plugins_cookie_path,
 972              'name' => $bb->secure_auth_cookie,
 973              'secure' => true
 974          );
 975      }
 976  
 977      /**
 978       * The current cookie version
 979       *
 980       * Version 1 is for WordPress >= 2.6 and < 2.8
 981       * Version 2 is for Wordpress >= 2.8
 982       */
 983      if ( !defined( 'WP_AUTH_COOKIE_VERSION' ) ) {
 984          define( 'WP_AUTH_COOKIE_VERSION', 2 );
 985      }
 986  
 987      /**
 988       * WP_Auth object
 989       */
 990      $wp_auth_object = new WP_Auth( $bbdb, $wp_users_object, $cookies );
 991  
 992      unset( $cookies );
 993  }
 994  
 995  /**
 996   * Current user object
 997   */
 998  $bb_current_user =& $wp_auth_object->current;
 999  
1000  // WP_Scripts/WP_Styles
1001  if ( !class_exists( 'WP_Dependencies' ) ) {
1002      require_once( BACKPRESS_PATH . 'class.wp-dependencies.php' );
1003  }
1004  
1005  if ( !class_exists( 'WP_Scripts' ) ) {
1006      require_once( BACKPRESS_PATH . 'class.wp-scripts.php' );
1007      require_once( BACKPRESS_PATH . 'functions.wp-scripts.php' );
1008  } else {
1009      unset( $wp_scripts );
1010  }
1011  
1012  if ( !class_exists( 'WP_Styles' ) ) {
1013      require_once( BACKPRESS_PATH . 'class.wp-styles.php' );
1014      require_once( BACKPRESS_PATH . 'functions.wp-styles.php' );
1015  } else {
1016      unset( $wp_styles );
1017  }
1018  
1019  
1020  
1021  // WP_Taxonomy
1022  if ( !class_exists( 'WP_Taxonomy' ) ) {
1023      require_once( BACKPRESS_PATH . 'class.wp-taxonomy.php' );
1024  }
1025  if ( !class_exists( 'BB_Taxonomy' ) ) {
1026      require_once( BB_PATH . BB_INC . 'class.bb-taxonomy.php' );
1027  }
1028  if ( !isset( $wp_taxonomy_object ) ) {
1029      // Clean slate
1030      $wp_taxonomy_object = new BB_Taxonomy( $bbdb );
1031  } elseif ( !is_a( $wp_taxonomy_object, 'BB_Taxonomy' ) ) {
1032      // exists, but it's not good enough, translate it
1033  
1034      // preserve the references
1035      $tax =& $wp_taxonomy_object->taxonomies;
1036      $wp_taxonomy_object = new BB_Taxonomy( $bbdb );
1037      $wp_taxonomy_object->taxonomies =& $tax;
1038      unset( $tax );
1039  }
1040  
1041  $wp_taxonomy_object->register_taxonomy( 'bb_topic_tag', 'bb_topic' );
1042  
1043  $wp_taxonomy_object->register_taxonomy( 'bb_subscribe', 'bb_user' );
1044  
1045  do_action( 'bb_options_loaded' );
1046  
1047  
1048  
1049  /**
1050   * Load deprecated constants and functions
1051   */
1052  
1053  // Skip loading of deprecated stuff unless specifically requested
1054  if ( BB_LOAD_DEPRECATED ) {
1055      /**
1056       * Define deprecated constants for plugin compatibility
1057       * $deprecated_constants below is a complete array of old constants and their replacements
1058       */
1059      $deprecated_constants = array(
1060          'BBPATH'      => 'BB_PATH',
1061          'BBINC'       => 'BB_INC',
1062          'BBLANG'      => 'BB_LANG',
1063          'BBLANGDIR'   => 'BB_LANG_DIR',
1064          'BBPLUGINDIR' => 'BB_PLUGIN_DIR',
1065          'BBPLUGINURL' => 'BB_PLUGIN_URL',
1066          'BBTHEMEDIR'  => 'BB_THEME_DIR',
1067          'BBTHEMEURL'  => 'BB_THEME_URL',
1068          'BBHASH'      => 'BB_HASH'
1069      );
1070      foreach ( $deprecated_constants as $old => $new ) {
1071          // only define if new one is defined
1072          if ( !defined( $old ) && defined( $new ) ) {
1073              define( $old, constant( $new ) );
1074          } elseif ( defined( $old ) ) {
1075              bb_log_deprecated( 'constant', $old, $new );
1076          }
1077      }
1078  
1079      $deprecated_constants = array(
1080          'USER_BBDB_NAME'         => 'user_bbdb_name',
1081          'USER_BBDB_USER'         => 'user_bbdb_user',
1082          'USER_BBDB_PASSWORD'     => 'user_bbdb_password',
1083          'USER_BBDB_HOST'         => 'user_bbdb_host',
1084          'USER_BBDB_CHARSET'      => 'user_bbdb_charset',
1085          'CUSTOM_USER_TABLE'      => 'custom_user_table',
1086          'CUSTOM_USER_META_TABLE' => 'custom_user_meta_table',
1087      );
1088      foreach ( $deprecated_constants as $old => $new ) {
1089          if ( !defined( $old ) ) {
1090              define( $old, $bb->$new );
1091          } else {
1092              bb_log_deprecated( 'constant', $old, '$bb->' . $new );
1093          }
1094      }
1095      unset($deprecated_constants, $old, $new);
1096  
1097      /**
1098       * Load deprecated functions
1099       */
1100      require_once( BB_PATH . BB_INC . 'functions.bb-deprecated.php' );
1101  
1102      /**
1103       * Old cache global object for backwards compatibility
1104       */
1105      $bb_cache = new BB_Cache();
1106  }
1107  
1108  
1109  
1110  /**
1111   * Load active template functions.php file
1112   */
1113  $template_functions_include = bb_get_active_theme_directory() . 'functions.php';
1114  if ( file_exists( $template_functions_include ) ) {
1115      require_once( $template_functions_include );
1116  }
1117  unset( $template_functions_include );
1118  
1119  
1120  
1121  /**
1122   * Load Plugins
1123   */
1124  
1125  // Skip plugin loading in "safe" mode
1126  if ( $bb->plugin_locations && ( !isset( $bb->safemode ) || $bb->safemode !== true ) ) {
1127      // Autoloaded "underscore" plugins
1128      foreach ( $bb->plugin_locations as $_name => $_data ) {
1129          foreach ( bb_glob( $_data['dir'] . '_*.php' ) as $_plugin ) {
1130              require_once( $_plugin );
1131          }
1132          unset( $_plugin );
1133      }
1134      unset( $_name, $_data );
1135      do_action( 'bb_underscore_plugins_loaded' );
1136  
1137      // Normal plugins
1138      if ( $_plugins = bb_get_option( 'active_plugins' ) ) {
1139          foreach ( (array) $_plugins as $_plugin ) {
1140              if ( !preg_match( '/^([a-z0-9_-]+)#((?:[a-z0-9\/\\_-]+.)+)(php)$/i', $_plugin, $_matches ) ) {
1141                  // The plugin entry in the database is invalid
1142                  continue;
1143              }
1144  
1145              $_directory = $bb->plugin_locations[$_matches[1]]['dir'];
1146              $_plugin = $_matches[2] . $_matches[3];
1147  
1148              if ( !$_plugin ) {
1149                  // Not likely
1150                  continue;
1151              }
1152  
1153              if ( validate_file( $_plugin ) ) {
1154                  // $plugin has .., :, etc.
1155                  continue;
1156              }
1157  
1158              if ( !file_exists( $_directory . $_plugin ) ) {
1159                  // The plugin isn't there
1160                  continue;
1161              }
1162  
1163              require_once( $_directory . $_plugin );
1164          }
1165      }
1166      unset( $_plugins, $_plugin, $_directory );
1167      do_action( 'bb_plugins_loaded' );
1168  }
1169  
1170  require_once( BB_PATH . BB_INC . 'functions.bb-pluggable.php' );
1171  
1172  
1173  
1174  /**
1175   * Reference to $wp_roles
1176   */
1177  $bb_roles =& $wp_roles;
1178  do_action( 'bb_got_roles' );
1179  
1180  
1181  
1182  /**
1183   * Create an API hook to run on shutdown
1184   */
1185  
1186  function bb_shutdown_action_hook() {
1187      do_action( 'bb_shutdown' );
1188  }
1189  register_shutdown_function( 'bb_shutdown_action_hook' );
1190  
1191  
1192  /**
1193   * Get details of the current user
1194   */
1195  
1196  bb_current_user();
1197  
1198  
1199  
1200  /**
1201   * Initialise CRON
1202   */
1203  
1204  if ( !function_exists( 'wp_schedule_single_event' ) ) {
1205      require_once( BACKPRESS_PATH . 'functions.wp-cron.php' );
1206  }
1207  if ( ( !defined('DOING_CRON') || !DOING_CRON ) ) {
1208      wp_cron();
1209  }
1210  
1211  
1212  
1213  /**
1214   * The currently viewed page number
1215   */
1216  $page = bb_get_uri_page();
1217  
1218  
1219  
1220  /**
1221   * Initialisation complete API hook
1222   */
1223  
1224  do_action( 'bb_init' );
1225  
1226  
1227  
1228  /**
1229   * Block user if they deserve it
1230   */
1231  
1232  if ( bb_is_user_logged_in() && bb_has_broken_pass() ) {
1233      bb_block_current_user();
1234  }
1235  
1236  
1237  
1238  /**
1239   * Send HTTP headers
1240   */
1241  
1242  bb_send_headers();


Generated: Thu Dec 7 01:01:35 2017 Cross-referenced by PHPXref 0.7.1