[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-core/ -> bp-core-update.php (source)

   1  <?php
   2  /**
   3   * BuddyPress Updater.
   4   *
   5   * @package BuddyPress
   6   * @subpackage Updater
   7   * @since 1.6.0
   8   */
   9  
  10  // Exit if accessed directly.
  11  defined( 'ABSPATH' ) || exit;
  12  
  13  /**
  14   * Is this a fresh installation of BuddyPress?
  15   *
  16   * If there is no raw DB version, we infer that this is the first installation.
  17   *
  18   * @since 1.7.0
  19   *
  20   * @return bool True if this is a fresh BP install, otherwise false.
  21   */
  22  function bp_is_install() {
  23      return ! bp_get_db_version_raw();
  24  }
  25  
  26  /**
  27   * Is this a BuddyPress update?
  28   *
  29   * Determined by comparing the registered BuddyPress version to the version
  30   * number stored in the database. If the registered version is greater, it's
  31   * an update.
  32   *
  33   * @since 1.6.0
  34   *
  35   * @return bool True if update, otherwise false.
  36   */
  37  function bp_is_update() {
  38  
  39      // Current DB version of this site (per site in a multisite network).
  40      $current_db   = bp_get_option( '_bp_db_version' );
  41      $current_live = bp_get_db_version();
  42  
  43      // Compare versions (cast as int and bool to be safe).
  44      $is_update = (bool) ( (int) $current_db < (int) $current_live );
  45  
  46      // Return the product of version comparison.
  47      return $is_update;
  48  }
  49  
  50  /**
  51   * Determine whether BuddyPress is in the process of being activated.
  52   *
  53   * @since 1.6.0
  54   *
  55   * @param string $basename BuddyPress basename.
  56   * @return bool True if activating BuddyPress, false if not.
  57   */
  58  function bp_is_activation( $basename = '' ) {
  59      $bp     = buddypress();
  60      $action = false;
  61  
  62      if ( ! empty( $_REQUEST['action'] ) && ( '-1' != $_REQUEST['action'] ) ) {
  63          $action = $_REQUEST['action'];
  64      } elseif ( ! empty( $_REQUEST['action2'] ) && ( '-1' != $_REQUEST['action2'] ) ) {
  65          $action = $_REQUEST['action2'];
  66      }
  67  
  68      // Bail if not activating.
  69      if ( empty( $action ) || !in_array( $action, array( 'activate', 'activate-selected' ) ) ) {
  70          return false;
  71      }
  72  
  73      // The plugin(s) being activated.
  74      if ( $action == 'activate' ) {
  75          $plugins = isset( $_GET['plugin'] ) ? array( $_GET['plugin'] ) : array();
  76      } else {
  77          $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
  78      }
  79  
  80      // Set basename if empty.
  81      if ( empty( $basename ) && !empty( $bp->basename ) ) {
  82          $basename = $bp->basename;
  83      }
  84  
  85      // Bail if no basename.
  86      if ( empty( $basename ) ) {
  87          return false;
  88      }
  89  
  90      // Is BuddyPress being activated?
  91      return in_array( $basename, $plugins );
  92  }
  93  
  94  /**
  95   * Determine whether BuddyPress is in the process of being deactivated.
  96   *
  97   * @since 1.6.0
  98   *
  99   * @param string $basename BuddyPress basename.
 100   * @return bool True if deactivating BuddyPress, false if not.
 101   */
 102  function bp_is_deactivation( $basename = '' ) {
 103      $bp     = buddypress();
 104      $action = false;
 105  
 106      if ( ! empty( $_REQUEST['action'] ) && ( '-1' != $_REQUEST['action'] ) ) {
 107          $action = $_REQUEST['action'];
 108      } elseif ( ! empty( $_REQUEST['action2'] ) && ( '-1' != $_REQUEST['action2'] ) ) {
 109          $action = $_REQUEST['action2'];
 110      }
 111  
 112      // Bail if not deactivating.
 113      if ( empty( $action ) || !in_array( $action, array( 'deactivate', 'deactivate-selected' ) ) ) {
 114          return false;
 115      }
 116  
 117      // The plugin(s) being deactivated.
 118      if ( 'deactivate' == $action ) {
 119          $plugins = isset( $_GET['plugin'] ) ? array( $_GET['plugin'] ) : array();
 120      } else {
 121          $plugins = isset( $_POST['checked'] ) ? (array) $_POST['checked'] : array();
 122      }
 123  
 124      // Set basename if empty.
 125      if ( empty( $basename ) && !empty( $bp->basename ) ) {
 126          $basename = $bp->basename;
 127      }
 128  
 129      // Bail if no basename.
 130      if ( empty( $basename ) ) {
 131          return false;
 132      }
 133  
 134      // Is bbPress being deactivated?
 135      return in_array( $basename, $plugins );
 136  }
 137  
 138  /**
 139   * Update the BP version stored in the database to the current version.
 140   *
 141   * @since 1.6.0
 142   */
 143  function bp_version_bump() {
 144      bp_update_option( '_bp_db_version', bp_get_db_version() );
 145  }
 146  
 147  /**
 148   * Set up the BuddyPress updater.
 149   *
 150   * @since 1.6.0
 151   */
 152  function bp_setup_updater() {
 153  
 154      // Are we running an outdated version of BuddyPress?
 155      if ( ! bp_is_update() ) {
 156          return;
 157      }
 158  
 159      bp_version_updater();
 160  }
 161  
 162  /**
 163   * Initialize an update or installation of BuddyPress.
 164   *
 165   * BuddyPress's version updater looks at what the current database version is,
 166   * and runs whatever other code is needed - either the "update" or "install"
 167   * code.
 168   *
 169   * This is most often used when the data schema changes, but should also be used
 170   * to correct issues with BuddyPress metadata silently on software update.
 171   *
 172   * @since 1.7.0
 173   */
 174  function bp_version_updater() {
 175  
 176      // Get the raw database version.
 177      $raw_db_version = (int) bp_get_db_version_raw();
 178  
 179      /**
 180       * Filters the default components to activate for a new install.
 181       *
 182       * @since 1.7.0
 183       *
 184       * @param array $value Array of default components to activate.
 185       */
 186      $default_components = apply_filters( 'bp_new_install_default_components', array(
 187          'activity'      => 1,
 188          'members'       => 1,
 189          'settings'      => 1,
 190          'xprofile'      => 1,
 191          'notifications' => 1,
 192      ) );
 193  
 194      require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
 195      require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
 196      $switched_to_root_blog = false;
 197  
 198      // Make sure the current blog is set to the root blog.
 199      if ( ! bp_is_root_blog() ) {
 200          switch_to_blog( bp_get_root_blog_id() );
 201          bp_register_taxonomies();
 202  
 203          $switched_to_root_blog = true;
 204      }
 205  
 206      // Install BP schema and activate only Activity and XProfile.
 207      if ( bp_is_install() ) {
 208  
 209          // Apply schema and set Activity and XProfile components as active.
 210          bp_core_install( $default_components );
 211          bp_update_option( 'bp-active-components', $default_components );
 212          bp_core_add_page_mappings( $default_components, 'delete' );
 213          bp_core_install_emails();
 214  
 215      // Upgrades.
 216      } else {
 217  
 218          // Run the schema install to update tables.
 219          bp_core_install();
 220  
 221          // Version 1.5.0.
 222          if ( $raw_db_version < 1801 ) {
 223              bp_update_to_1_5();
 224              bp_core_add_page_mappings( $default_components, 'delete' );
 225          }
 226  
 227          // Version 1.6.0.
 228          if ( $raw_db_version < 6067 ) {
 229              bp_update_to_1_6();
 230          }
 231  
 232          // Version 1.9.0.
 233          if ( $raw_db_version < 7553 ) {
 234              bp_update_to_1_9();
 235          }
 236  
 237          // Version 1.9.2.
 238          if ( $raw_db_version < 7731 ) {
 239              bp_update_to_1_9_2();
 240          }
 241  
 242          // Version 2.0.0.
 243          if ( $raw_db_version < 7892 ) {
 244              bp_update_to_2_0();
 245          }
 246  
 247          // Version 2.0.1.
 248          if ( $raw_db_version < 8311 ) {
 249              bp_update_to_2_0_1();
 250          }
 251  
 252          // Version 2.2.0.
 253          if ( $raw_db_version < 9181 ) {
 254              bp_update_to_2_2();
 255          }
 256  
 257          // Version 2.3.0.
 258          if ( $raw_db_version < 9615 ) {
 259              bp_update_to_2_3();
 260          }
 261  
 262          // Version 2.5.0.
 263          if ( $raw_db_version < 10440 ) {
 264              bp_update_to_2_5();
 265          }
 266  
 267          // Version 2.7.0.
 268          if ( $raw_db_version < 11105 ) {
 269              bp_update_to_2_7();
 270          }
 271  
 272          // Version 5.0.0.
 273          if ( $raw_db_version < 12385 ) {
 274              bp_update_to_5_0();
 275          }
 276      }
 277  
 278      /* All done! *************************************************************/
 279  
 280      // Bump the version.
 281      bp_version_bump();
 282  
 283      if ( $switched_to_root_blog ) {
 284          restore_current_blog();
 285      }
 286  }
 287  
 288  /**
 289   * Perform database operations that must take place before the general schema upgrades.
 290   *
 291   * `dbDelta()` cannot handle certain operations - like changing indexes - so we do it here instead.
 292   *
 293   * @since 2.3.0
 294   */
 295  function bp_pre_schema_upgrade() {
 296      global $wpdb;
 297  
 298      $raw_db_version = (int) bp_get_db_version_raw();
 299      $bp_prefix      = bp_core_get_table_prefix();
 300  
 301      // 2.3.0: Change index lengths to account for utf8mb4.
 302      if ( $raw_db_version < 9695 ) {
 303          // Map table_name => columns.
 304          $tables = array(
 305              $bp_prefix . 'bp_activity_meta'       => array( 'meta_key' ),
 306              $bp_prefix . 'bp_groups_groupmeta'    => array( 'meta_key' ),
 307              $bp_prefix . 'bp_messages_meta'       => array( 'meta_key' ),
 308              $bp_prefix . 'bp_notifications_meta'  => array( 'meta_key' ),
 309              $bp_prefix . 'bp_user_blogs_blogmeta' => array( 'meta_key' ),
 310              $bp_prefix . 'bp_xprofile_meta'       => array( 'meta_key' ),
 311          );
 312  
 313          foreach ( $tables as $table_name => $indexes ) {
 314              foreach ( $indexes as $index ) {
 315                  if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", bp_esc_like( $table_name ) ) ) ) {
 316                      $wpdb->query( "ALTER TABLE {$table_name} DROP INDEX {$index}" );
 317                  }
 318              }
 319          }
 320      }
 321  }
 322  
 323  /** Upgrade Routines **********************************************************/
 324  
 325  /**
 326   * Remove unused metadata from database when upgrading from < 1.5.
 327   *
 328   * Database update methods based on version numbers.
 329   *
 330   * @since 1.7.0
 331   */
 332  function bp_update_to_1_5() {
 333  
 334      // Delete old database version options.
 335      delete_site_option( 'bp-activity-db-version' );
 336      delete_site_option( 'bp-blogs-db-version'    );
 337      delete_site_option( 'bp-friends-db-version'  );
 338      delete_site_option( 'bp-groups-db-version'   );
 339      delete_site_option( 'bp-messages-db-version' );
 340      delete_site_option( 'bp-xprofile-db-version' );
 341  }
 342  
 343  /**
 344   * Remove unused metadata from database when upgrading from < 1.6.0.
 345   *
 346   * Database update methods based on version numbers.
 347   *
 348   * @since 1.7.0
 349   */
 350  function bp_update_to_1_6() {
 351  
 352      // Delete possible site options.
 353      delete_site_option( 'bp-db-version'       );
 354      delete_site_option( '_bp_db_version'      );
 355      delete_site_option( 'bp-core-db-version'  );
 356      delete_site_option( '_bp-core-db-version' );
 357  
 358      // Delete possible blog options.
 359      delete_blog_option( bp_get_root_blog_id(), 'bp-db-version'       );
 360      delete_blog_option( bp_get_root_blog_id(), 'bp-core-db-version'  );
 361      delete_site_option( bp_get_root_blog_id(), '_bp-core-db-version' );
 362      delete_site_option( bp_get_root_blog_id(), '_bp_db_version'      );
 363  }
 364  
 365  /**
 366   * Add the notifications component to active components.
 367   *
 368   * Notifications was added in 1.9.0, and previous installations will already
 369   * have the core notifications API active. We need to add the new Notifications
 370   * component to the active components option to retain existing functionality.
 371   *
 372   * @since 1.9.0
 373   */
 374  function bp_update_to_1_9() {
 375  
 376      // Setup hardcoded keys.
 377      $active_components_key      = 'bp-active-components';
 378      $notifications_component_id = 'notifications';
 379  
 380      // Get the active components.
 381      $active_components          = bp_get_option( $active_components_key );
 382  
 383      // Add notifications.
 384      if ( ! in_array( $notifications_component_id, $active_components ) ) {
 385          $active_components[ $notifications_component_id ] = 1;
 386      }
 387  
 388      // Update the active components option.
 389      bp_update_option( $active_components_key, $active_components );
 390  }
 391  
 392  /**
 393   * Perform database updates for BP 1.9.2.
 394   *
 395   * In 1.9, BuddyPress stopped registering its theme directory when it detected
 396   * that bp-default (or a child theme) was not currently being used, in effect
 397   * deprecating bp-default. However, this ended up causing problems when site
 398   * admins using bp-default would switch away from the theme temporarily:
 399   * bp-default would no longer be available, with no obvious way (outside of
 400   * a manual filter) to restore it. In 1.9.2, we add an option that flags
 401   * whether bp-default or a child theme is active at the time of upgrade; if so,
 402   *
 403   * the theme directory will continue to be registered even if the theme is
 404   * deactivated temporarily. Thus, new installations will not see bp-default,
 405   * but legacy installations using the theme will continue to see it.
 406   *
 407   * @since 1.9.2
 408   */
 409  function bp_update_to_1_9_2() {
 410      if ( 'bp-default' === get_stylesheet() || 'bp-default' === get_template() ) {
 411          update_site_option( '_bp_retain_bp_default', 1 );
 412      }
 413  }
 414  
 415  /**
 416   * 2.0 update routine.
 417   *
 418   * - Ensure that the activity tables are installed, for last_activity storage.
 419   * - Migrate last_activity data from usermeta to activity table.
 420   * - Add values for all BuddyPress options to the options table.
 421   *
 422   * @since 2.0.0
 423   */
 424  function bp_update_to_2_0() {
 425  
 426      /* Install activity tables for 'last_activity' ***************************/
 427  
 428      bp_core_install_activity_streams();
 429  
 430      /* Migrate 'last_activity' data ******************************************/
 431  
 432      bp_last_activity_migrate();
 433  
 434      /* Migrate signups data **************************************************/
 435  
 436      if ( ! is_multisite() ) {
 437  
 438          // Maybe install the signups table.
 439          bp_core_maybe_install_signups();
 440  
 441          // Run the migration script.
 442          bp_members_migrate_signups();
 443      }
 444  
 445      /* Add BP options to the options table ***********************************/
 446  
 447      bp_add_options();
 448  }
 449  
 450  /**
 451   * 2.0.1 database upgrade routine.
 452   *
 453   * @since 2.0.1
 454   */
 455  function bp_update_to_2_0_1() {
 456  
 457      // We purposely call this during both the 2.0 upgrade and the 2.0.1 upgrade.
 458      // Don't worry; it won't break anything, and safely handles all cases.
 459      bp_core_maybe_install_signups();
 460  }
 461  
 462  /**
 463   * 2.2.0 update routine.
 464   *
 465   * - Add messages meta table.
 466   * - Update the component field of the 'new members' activity type.
 467   * - Clean up hidden friendship activities.
 468   *
 469   * @since 2.2.0
 470   */
 471  function bp_update_to_2_2() {
 472  
 473      // Also handled by `bp_core_install()`.
 474      if ( bp_is_active( 'messages' ) ) {
 475          bp_core_install_private_messaging();
 476      }
 477  
 478      if ( bp_is_active( 'activity' ) ) {
 479          bp_migrate_new_member_activity_component();
 480  
 481          if ( bp_is_active( 'friends' ) ) {
 482              bp_cleanup_friendship_activities();
 483          }
 484      }
 485  }
 486  
 487  /**
 488   * 2.3.0 update routine.
 489   *
 490   * - Add notifications meta table.
 491   *
 492   * @since 2.3.0
 493   */
 494  function bp_update_to_2_3() {
 495  
 496      // Also handled by `bp_core_install()`.
 497      if ( bp_is_active( 'notifications' ) ) {
 498          bp_core_install_notifications();
 499      }
 500  }
 501  
 502  /**
 503   * 2.5.0 update routine.
 504   *
 505   * - Add emails.
 506   *
 507   * @since 2.5.0
 508   */
 509  function bp_update_to_2_5() {
 510      bp_core_install_emails();
 511  }
 512  
 513  /**
 514   * 2.7.0 update routine.
 515   *
 516   * - Add email unsubscribe salt.
 517   * - Save legacy directory titles to the corresponding WP pages.
 518   * - Add ignore deprecated code option (false for updates).
 519   *
 520   * @since 2.7.0
 521   */
 522  function bp_update_to_2_7() {
 523      bp_add_option( 'bp-emails-unsubscribe-salt', base64_encode( wp_generate_password( 64, true, true ) ) );
 524  
 525      // Update post_titles
 526      bp_migrate_directory_page_titles();
 527  
 528      /*
 529       * Add `parent_id` column to groups table.
 530       * Also handled by `bp_core_install()`.
 531       */
 532      if ( bp_is_active( 'groups' ) ) {
 533          bp_core_install_groups();
 534  
 535          // Invalidate all cached group objects.
 536          global $wpdb;
 537          $bp = buddypress();
 538  
 539          $group_ids = $wpdb->get_col( "SELECT id FROM {$bp->groups->table_name}" );
 540  
 541          foreach ( $group_ids as $group_id ) {
 542              wp_cache_delete( $group_id, 'bp_groups' );
 543          }
 544      }
 545  
 546      // Do not ignore deprecated code for existing installs.
 547      bp_add_option( '_bp_ignore_deprecated_code', false );
 548  }
 549  
 550  /**
 551   * 5.0.0 update routine.
 552   *
 553   * - Make sure the custom visibility is disabled for the default profile field.
 554   *
 555   * @since 5.0.0
 556   */
 557  function bp_update_to_5_0() {
 558      /**
 559       * The xProfile component is active by default on new installs, even if it
 560       * might be inactive during this update, we need to set the custom visibility
 561       * for the default field, in case the Administrator decides to reactivate it.
 562       */
 563      global $wpdb;
 564      $bp_prefix = bp_core_get_table_prefix();
 565      $field_id  = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$bp_prefix}bp_xprofile_fields WHERE name = %s", addslashes( bp_get_option( 'bp-xprofile-fullname-field-name' ) ) ) );
 566  
 567      $wpdb->insert(
 568          $bp_prefix . 'bp_xprofile_meta',
 569          array(
 570              'object_id'   => $field_id,
 571              'object_type' => 'field',
 572              'meta_key'    => 'allow_custom_visibility',
 573              'meta_value'  => 'disabled'
 574          ),
 575          array(
 576              '%d',
 577              '%s',
 578              '%s',
 579              '%s'
 580          )
 581      );
 582  }
 583  
 584  /**
 585   * Updates the component field for new_members type.
 586   *
 587   * @since 2.2.0
 588   *
 589   * @global $wpdb
 590   */
 591  function bp_migrate_new_member_activity_component() {
 592      global $wpdb;
 593      $bp = buddypress();
 594  
 595      // Update the component for the new_member type.
 596      $wpdb->update(
 597          // Activity table.
 598          $bp->members->table_name_last_activity,
 599          array(
 600              'component' => $bp->members->id,
 601          ),
 602          array(
 603              'component' => 'xprofile',
 604              'type'      => 'new_member',
 605          ),
 606          // Data sanitization format.
 607          array(
 608              '%s',
 609          ),
 610          // WHERE sanitization format.
 611          array(
 612              '%s',
 613              '%s'
 614          )
 615      );
 616  }
 617  
 618  /**
 619   * Remove all hidden friendship activities.
 620   *
 621   * @since 2.2.0
 622   */
 623  function bp_cleanup_friendship_activities() {
 624      bp_activity_delete( array(
 625          'component'     => buddypress()->friends->id,
 626          'type'          => 'friendship_created',
 627          'hide_sitewide' => true,
 628      ) );
 629  }
 630  
 631  /**
 632   * Update WP pages so that their post_title matches the legacy component directory title.
 633   *
 634   * As of 2.7.0, component directory titles come from the `post_title` attribute of the corresponding WP post object,
 635   * instead of being hardcoded. To ensure that directory titles don't change for existing installations, we update these
 636   * WP posts with the formerly hardcoded titles.
 637   *
 638   * @since 2.7.0
 639   */
 640  function bp_migrate_directory_page_titles() {
 641      $bp_pages = bp_core_get_directory_page_ids( 'all' );
 642  
 643      $default_titles = bp_core_get_directory_page_default_titles();
 644  
 645      $legacy_titles = array(
 646          'activity' => _x( 'Site-Wide Activity', 'component directory title', 'buddypress' ),
 647          'blogs'    => _x( 'Sites', 'component directory title', 'buddypress' ),
 648          'groups'   => _x( 'Groups', 'component directory title', 'buddypress' ),
 649          'members'  => _x( 'Members', 'component directory title', 'buddypress' ),
 650      );
 651  
 652      foreach ( $bp_pages as $component => $page_id ) {
 653          if ( ! isset( $legacy_titles[ $component ] ) ) {
 654              continue;
 655          }
 656  
 657          $page = get_post( $page_id );
 658          if ( ! $page ) {
 659              continue;
 660          }
 661  
 662          // If the admin has changed the default title, don't touch it.
 663          if ( isset( $default_titles[ $component ] ) && $default_titles[ $component ] !== $page->post_title ) {
 664              continue;
 665          }
 666  
 667          // If the saved page title is the same as the legacy title, there's nothing to do.
 668          if ( $legacy_titles[ $component ] == $page->post_title ) {
 669              continue;
 670          }
 671  
 672          // Update the page with the legacy title.
 673          wp_update_post( array(
 674              'ID' => $page_id,
 675              'post_title' => $legacy_titles[ $component ],
 676          ) );
 677      }
 678  }
 679  
 680  /**
 681   * Redirect user to BP's What's New page on first page load after activation.
 682   *
 683   * @since 1.7.0
 684   *
 685   * @internal Used internally to redirect BuddyPress to the about page on activation.
 686   */
 687  function bp_add_activation_redirect() {
 688  
 689      // Bail if activating from network, or bulk.
 690      if ( isset( $_GET['activate-multi'] ) ) {
 691          return;
 692      }
 693  
 694      // Record that this is a new installation, so we show the right
 695      // welcome message.
 696      if ( bp_is_install() ) {
 697          set_transient( '_bp_is_new_install', true, 30 );
 698      }
 699  
 700      // Add the transient to redirect.
 701      set_transient( '_bp_activation_redirect', true, 30 );
 702  }
 703  
 704  /** Signups *******************************************************************/
 705  
 706  /**
 707   * Check if the signups table needs to be created or upgraded.
 708   *
 709   * @since 2.0.0
 710   *
 711   * @global WPDB $wpdb
 712   */
 713  function bp_core_maybe_install_signups() {
 714      global $wpdb;
 715  
 716      // The table to run queries against.
 717      $signups_table = $wpdb->base_prefix . 'signups';
 718  
 719      // Suppress errors because users shouldn't see what happens next.
 720      $old_suppress  = $wpdb->suppress_errors();
 721  
 722      // Never use bp_core_get_table_prefix() for any global users tables.
 723      $table_exists  = (bool) $wpdb->get_results( "DESCRIBE {$signups_table};" );
 724  
 725      // Table already exists, so maybe upgrade instead?
 726      if ( true === $table_exists ) {
 727  
 728          // Look for the 'signup_id' column.
 729          $column_exists = $wpdb->query( "SHOW COLUMNS FROM {$signups_table} LIKE 'signup_id'" );
 730  
 731          // 'signup_id' column doesn't exist, so run the upgrade
 732          if ( empty( $column_exists ) ) {
 733              bp_core_upgrade_signups();
 734          }
 735  
 736      // Table does not exist, and we are a single site, so install the multisite
 737      // signups table using WordPress core's database schema.
 738      } elseif ( ! is_multisite() ) {
 739          bp_core_install_signups();
 740      }
 741  
 742      // Restore previous error suppression setting.
 743      $wpdb->suppress_errors( $old_suppress );
 744  }
 745  
 746  /** Activation Actions ********************************************************/
 747  
 748  /**
 749   * Fire activation hooks and events.
 750   *
 751   * Runs on BuddyPress activation.
 752   *
 753   * @since 1.6.0
 754   */
 755  function bp_activation() {
 756  
 757      // Force refresh theme roots.
 758      delete_site_transient( 'theme_roots' );
 759  
 760      // Add options.
 761      bp_add_options();
 762  
 763      /**
 764       * Fires during the activation of BuddyPress.
 765       *
 766       * Use as of 1.6.0.
 767       *
 768       * @since 1.6.0
 769       */
 770      do_action( 'bp_activation' );
 771  
 772      // @deprecated as of 1.6.0
 773      do_action( 'bp_loader_activate' );
 774  }
 775  
 776  /**
 777   * Fire deactivation hooks and events.
 778   *
 779   * Runs on BuddyPress deactivation.
 780   *
 781   * @since 1.6.0
 782   */
 783  function bp_deactivation() {
 784  
 785      // Force refresh theme roots.
 786      delete_site_transient( 'theme_roots' );
 787  
 788      // Switch to WordPress's default theme if current parent or child theme
 789      // depend on bp-default. This is to prevent white screens of doom.
 790      if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) ) {
 791          switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
 792          update_option( 'template_root',   get_raw_theme_root( WP_DEFAULT_THEME, true ) );
 793          update_option( 'stylesheet_root', get_raw_theme_root( WP_DEFAULT_THEME, true ) );
 794      }
 795  
 796      /**
 797       * Fires during the deactivation of BuddyPress.
 798       *
 799       * Use as of 1.6.0.
 800       *
 801       * @since 1.6.0
 802       */
 803      do_action( 'bp_deactivation' );
 804  
 805      // @deprecated as of 1.6.0
 806      do_action( 'bp_loader_deactivate' );
 807  }
 808  
 809  /**
 810   * Fire uninstall hook.
 811   *
 812   * Runs when uninstalling BuddyPress.
 813   *
 814   * @since 1.6.0
 815   */
 816  function bp_uninstall() {
 817  
 818      /**
 819       * Fires during the uninstallation of BuddyPress.
 820       *
 821       * @since 1.6.0
 822       */
 823      do_action( 'bp_uninstall' );
 824  }


Generated: Wed Jul 24 01:01:43 2019 Cross-referenced by PHPXref 0.7.1