[ 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          bp_core_install_invitations();
 215  
 216      // Upgrades.
 217      } else {
 218  
 219          // Run the schema install to update tables.
 220          bp_core_install();
 221  
 222          // Version 1.5.0.
 223          if ( $raw_db_version < 1801 ) {
 224              bp_update_to_1_5();
 225              bp_core_add_page_mappings( $default_components, 'delete' );
 226          }
 227  
 228          // Version 1.6.0.
 229          if ( $raw_db_version < 6067 ) {
 230              bp_update_to_1_6();
 231          }
 232  
 233          // Version 1.9.0.
 234          if ( $raw_db_version < 7553 ) {
 235              bp_update_to_1_9();
 236          }
 237  
 238          // Version 1.9.2.
 239          if ( $raw_db_version < 7731 ) {
 240              bp_update_to_1_9_2();
 241          }
 242  
 243          // Version 2.0.0.
 244          if ( $raw_db_version < 7892 ) {
 245              bp_update_to_2_0();
 246          }
 247  
 248          // Version 2.0.1.
 249          if ( $raw_db_version < 8311 ) {
 250              bp_update_to_2_0_1();
 251          }
 252  
 253          // Version 2.2.0.
 254          if ( $raw_db_version < 9181 ) {
 255              bp_update_to_2_2();
 256          }
 257  
 258          // Version 2.3.0.
 259          if ( $raw_db_version < 9615 ) {
 260              bp_update_to_2_3();
 261          }
 262  
 263          // Version 2.5.0.
 264          if ( $raw_db_version < 10440 ) {
 265              bp_update_to_2_5();
 266          }
 267  
 268          // Version 2.7.0.
 269          if ( $raw_db_version < 11105 ) {
 270              bp_update_to_2_7();
 271          }
 272  
 273          // Version 5.0.0.
 274          if ( $raw_db_version < 12385 ) {
 275              bp_update_to_5_0();
 276          }
 277      }
 278  
 279      /* All done! *************************************************************/
 280  
 281      // Bump the version.
 282      bp_version_bump();
 283  
 284      if ( $switched_to_root_blog ) {
 285          restore_current_blog();
 286      }
 287  }
 288  
 289  /**
 290   * Perform database operations that must take place before the general schema upgrades.
 291   *
 292   * `dbDelta()` cannot handle certain operations - like changing indexes - so we do it here instead.
 293   *
 294   * @since 2.3.0
 295   */
 296  function bp_pre_schema_upgrade() {
 297      global $wpdb;
 298  
 299      $raw_db_version = (int) bp_get_db_version_raw();
 300      $bp_prefix      = bp_core_get_table_prefix();
 301  
 302      // 2.3.0: Change index lengths to account for utf8mb4.
 303      if ( $raw_db_version < 9695 ) {
 304          // Map table_name => columns.
 305          $tables = array(
 306              $bp_prefix . 'bp_activity_meta'       => array( 'meta_key' ),
 307              $bp_prefix . 'bp_groups_groupmeta'    => array( 'meta_key' ),
 308              $bp_prefix . 'bp_messages_meta'       => array( 'meta_key' ),
 309              $bp_prefix . 'bp_notifications_meta'  => array( 'meta_key' ),
 310              $bp_prefix . 'bp_user_blogs_blogmeta' => array( 'meta_key' ),
 311              $bp_prefix . 'bp_xprofile_meta'       => array( 'meta_key' ),
 312          );
 313  
 314          foreach ( $tables as $table_name => $indexes ) {
 315              foreach ( $indexes as $index ) {
 316                  if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", bp_esc_like( $table_name ) ) ) ) {
 317                      $wpdb->query( "ALTER TABLE {$table_name} DROP INDEX {$index}" );
 318                  }
 319              }
 320          }
 321      }
 322  }
 323  
 324  /** Upgrade Routines **********************************************************/
 325  
 326  /**
 327   * Remove unused metadata from database when upgrading from < 1.5.
 328   *
 329   * Database update methods based on version numbers.
 330   *
 331   * @since 1.7.0
 332   */
 333  function bp_update_to_1_5() {
 334  
 335      // Delete old database version options.
 336      delete_site_option( 'bp-activity-db-version' );
 337      delete_site_option( 'bp-blogs-db-version'    );
 338      delete_site_option( 'bp-friends-db-version'  );
 339      delete_site_option( 'bp-groups-db-version'   );
 340      delete_site_option( 'bp-messages-db-version' );
 341      delete_site_option( 'bp-xprofile-db-version' );
 342  }
 343  
 344  /**
 345   * Remove unused metadata from database when upgrading from < 1.6.0.
 346   *
 347   * Database update methods based on version numbers.
 348   *
 349   * @since 1.7.0
 350   */
 351  function bp_update_to_1_6() {
 352  
 353      // Delete possible site options.
 354      delete_site_option( 'bp-db-version'       );
 355      delete_site_option( '_bp_db_version'      );
 356      delete_site_option( 'bp-core-db-version'  );
 357      delete_site_option( '_bp-core-db-version' );
 358  
 359      // Delete possible blog options.
 360      delete_blog_option( bp_get_root_blog_id(), 'bp-db-version'       );
 361      delete_blog_option( bp_get_root_blog_id(), 'bp-core-db-version'  );
 362      delete_site_option( bp_get_root_blog_id(), '_bp-core-db-version' );
 363      delete_site_option( bp_get_root_blog_id(), '_bp_db_version'      );
 364  }
 365  
 366  /**
 367   * Add the notifications component to active components.
 368   *
 369   * Notifications was added in 1.9.0, and previous installations will already
 370   * have the core notifications API active. We need to add the new Notifications
 371   * component to the active components option to retain existing functionality.
 372   *
 373   * @since 1.9.0
 374   */
 375  function bp_update_to_1_9() {
 376  
 377      // Setup hardcoded keys.
 378      $active_components_key      = 'bp-active-components';
 379      $notifications_component_id = 'notifications';
 380  
 381      // Get the active components.
 382      $active_components          = bp_get_option( $active_components_key );
 383  
 384      // Add notifications.
 385      if ( ! in_array( $notifications_component_id, $active_components ) ) {
 386          $active_components[ $notifications_component_id ] = 1;
 387      }
 388  
 389      // Update the active components option.
 390      bp_update_option( $active_components_key, $active_components );
 391  }
 392  
 393  /**
 394   * Perform database updates for BP 1.9.2.
 395   *
 396   * In 1.9, BuddyPress stopped registering its theme directory when it detected
 397   * that bp-default (or a child theme) was not currently being used, in effect
 398   * deprecating bp-default. However, this ended up causing problems when site
 399   * admins using bp-default would switch away from the theme temporarily:
 400   * bp-default would no longer be available, with no obvious way (outside of
 401   * a manual filter) to restore it. In 1.9.2, we add an option that flags
 402   * whether bp-default or a child theme is active at the time of upgrade; if so,
 403   *
 404   * the theme directory will continue to be registered even if the theme is
 405   * deactivated temporarily. Thus, new installations will not see bp-default,
 406   * but legacy installations using the theme will continue to see it.
 407   *
 408   * @since 1.9.2
 409   */
 410  function bp_update_to_1_9_2() {
 411      if ( 'bp-default' === get_stylesheet() || 'bp-default' === get_template() ) {
 412          update_site_option( '_bp_retain_bp_default', 1 );
 413      }
 414  }
 415  
 416  /**
 417   * 2.0 update routine.
 418   *
 419   * - Ensure that the activity tables are installed, for last_activity storage.
 420   * - Migrate last_activity data from usermeta to activity table.
 421   * - Add values for all BuddyPress options to the options table.
 422   *
 423   * @since 2.0.0
 424   */
 425  function bp_update_to_2_0() {
 426  
 427      /* Install activity tables for 'last_activity' ***************************/
 428  
 429      bp_core_install_activity_streams();
 430  
 431      /* Migrate 'last_activity' data ******************************************/
 432  
 433      bp_last_activity_migrate();
 434  
 435      /* Migrate signups data **************************************************/
 436  
 437      if ( ! is_multisite() ) {
 438  
 439          // Maybe install the signups table.
 440          bp_core_maybe_install_signups();
 441  
 442          // Run the migration script.
 443          bp_members_migrate_signups();
 444      }
 445  
 446      /* Add BP options to the options table ***********************************/
 447  
 448      bp_add_options();
 449  }
 450  
 451  /**
 452   * 2.0.1 database upgrade routine.
 453   *
 454   * @since 2.0.1
 455   */
 456  function bp_update_to_2_0_1() {
 457  
 458      // We purposely call this during both the 2.0 upgrade and the 2.0.1 upgrade.
 459      // Don't worry; it won't break anything, and safely handles all cases.
 460      bp_core_maybe_install_signups();
 461  }
 462  
 463  /**
 464   * 2.2.0 update routine.
 465   *
 466   * - Add messages meta table.
 467   * - Update the component field of the 'new members' activity type.
 468   * - Clean up hidden friendship activities.
 469   *
 470   * @since 2.2.0
 471   */
 472  function bp_update_to_2_2() {
 473  
 474      // Also handled by `bp_core_install()`.
 475      if ( bp_is_active( 'messages' ) ) {
 476          bp_core_install_private_messaging();
 477      }
 478  
 479      if ( bp_is_active( 'activity' ) ) {
 480          bp_migrate_new_member_activity_component();
 481  
 482          if ( bp_is_active( 'friends' ) ) {
 483              bp_cleanup_friendship_activities();
 484          }
 485      }
 486  }
 487  
 488  /**
 489   * 2.3.0 update routine.
 490   *
 491   * - Add notifications meta table.
 492   *
 493   * @since 2.3.0
 494   */
 495  function bp_update_to_2_3() {
 496  
 497      // Also handled by `bp_core_install()`.
 498      if ( bp_is_active( 'notifications' ) ) {
 499          bp_core_install_notifications();
 500      }
 501  }
 502  
 503  /**
 504   * 2.5.0 update routine.
 505   *
 506   * - Add emails.
 507   *
 508   * @since 2.5.0
 509   */
 510  function bp_update_to_2_5() {
 511      bp_core_install_emails();
 512  }
 513  
 514  /**
 515   * 2.7.0 update routine.
 516   *
 517   * - Add email unsubscribe salt.
 518   * - Save legacy directory titles to the corresponding WP pages.
 519   * - Add ignore deprecated code option (false for updates).
 520   *
 521   * @since 2.7.0
 522   */
 523  function bp_update_to_2_7() {
 524      bp_add_option( 'bp-emails-unsubscribe-salt', base64_encode( wp_generate_password( 64, true, true ) ) );
 525  
 526      // Update post_titles
 527      bp_migrate_directory_page_titles();
 528  
 529      /*
 530       * Add `parent_id` column to groups table.
 531       * Also handled by `bp_core_install()`.
 532       */
 533      if ( bp_is_active( 'groups' ) ) {
 534          bp_core_install_groups();
 535  
 536          // Invalidate all cached group objects.
 537          global $wpdb;
 538          $bp = buddypress();
 539  
 540          $group_ids = $wpdb->get_col( "SELECT id FROM {$bp->groups->table_name}" );
 541  
 542          foreach ( $group_ids as $group_id ) {
 543              wp_cache_delete( $group_id, 'bp_groups' );
 544          }
 545      }
 546  
 547      // Do not ignore deprecated code for existing installs.
 548      bp_add_option( '_bp_ignore_deprecated_code', false );
 549  }
 550  
 551  /**
 552   * 5.0.0 update routine.
 553   *
 554   * - Make sure the custom visibility is disabled for the default profile field.
 555   * - Create the invitations table.
 556   * - Migrate requests and invitations to the new table.
 557   *
 558   * @since 5.0.0
 559   */
 560  function bp_update_to_5_0() {
 561      /**
 562       * The xProfile component is active by default on new installs, even if it
 563       * might be inactive during this update, we need to set the custom visibility
 564       * for the default field, in case the Administrator decides to reactivate it.
 565       */
 566      global $wpdb;
 567      $bp_prefix = bp_core_get_table_prefix();
 568      $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' ) ) ) );
 569  
 570      $wpdb->insert(
 571          $bp_prefix . 'bp_xprofile_meta',
 572          array(
 573              'object_id'   => $field_id,
 574              'object_type' => 'field',
 575              'meta_key'    => 'allow_custom_visibility',
 576              'meta_value'  => 'disabled'
 577          ),
 578          array(
 579              '%d',
 580              '%s',
 581              '%s',
 582              '%s'
 583          )
 584      );
 585  
 586      bp_core_install_invitations();
 587  
 588      if ( bp_is_active( 'groups' ) ) {
 589          bp_groups_migrate_invitations();
 590      }
 591  }
 592  
 593  /**
 594   * Updates the component field for new_members type.
 595   *
 596   * @since 2.2.0
 597   *
 598   * @global $wpdb
 599   */
 600  function bp_migrate_new_member_activity_component() {
 601      global $wpdb;
 602      $bp = buddypress();
 603  
 604      // Update the component for the new_member type.
 605      $wpdb->update(
 606          // Activity table.
 607          $bp->members->table_name_last_activity,
 608          array(
 609              'component' => $bp->members->id,
 610          ),
 611          array(
 612              'component' => 'xprofile',
 613              'type'      => 'new_member',
 614          ),
 615          // Data sanitization format.
 616          array(
 617              '%s',
 618          ),
 619          // WHERE sanitization format.
 620          array(
 621              '%s',
 622              '%s'
 623          )
 624      );
 625  }
 626  
 627  /**
 628   * Remove all hidden friendship activities.
 629   *
 630   * @since 2.2.0
 631   */
 632  function bp_cleanup_friendship_activities() {
 633      bp_activity_delete( array(
 634          'component'     => buddypress()->friends->id,
 635          'type'          => 'friendship_created',
 636          'hide_sitewide' => true,
 637      ) );
 638  }
 639  
 640  /**
 641   * Update WP pages so that their post_title matches the legacy component directory title.
 642   *
 643   * As of 2.7.0, component directory titles come from the `post_title` attribute of the corresponding WP post object,
 644   * instead of being hardcoded. To ensure that directory titles don't change for existing installations, we update these
 645   * WP posts with the formerly hardcoded titles.
 646   *
 647   * @since 2.7.0
 648   */
 649  function bp_migrate_directory_page_titles() {
 650      $bp_pages = bp_core_get_directory_page_ids( 'all' );
 651  
 652      $default_titles = bp_core_get_directory_page_default_titles();
 653  
 654      $legacy_titles = array(
 655          'activity' => _x( 'Site-Wide Activity', 'component directory title', 'buddypress' ),
 656          'blogs'    => _x( 'Sites', 'component directory title', 'buddypress' ),
 657          'groups'   => _x( 'Groups', 'component directory title', 'buddypress' ),
 658          'members'  => _x( 'Members', 'component directory title', 'buddypress' ),
 659      );
 660  
 661      foreach ( $bp_pages as $component => $page_id ) {
 662          if ( ! isset( $legacy_titles[ $component ] ) ) {
 663              continue;
 664          }
 665  
 666          $page = get_post( $page_id );
 667          if ( ! $page ) {
 668              continue;
 669          }
 670  
 671          // If the admin has changed the default title, don't touch it.
 672          if ( isset( $default_titles[ $component ] ) && $default_titles[ $component ] !== $page->post_title ) {
 673              continue;
 674          }
 675  
 676          // If the saved page title is the same as the legacy title, there's nothing to do.
 677          if ( $legacy_titles[ $component ] == $page->post_title ) {
 678              continue;
 679          }
 680  
 681          // Update the page with the legacy title.
 682          wp_update_post( array(
 683              'ID' => $page_id,
 684              'post_title' => $legacy_titles[ $component ],
 685          ) );
 686      }
 687  }
 688  
 689  /**
 690   * Redirect user to BP's What's New page on first page load after activation.
 691   *
 692   * @since 1.7.0
 693   *
 694   * @internal Used internally to redirect BuddyPress to the about page on activation.
 695   */
 696  function bp_add_activation_redirect() {
 697  
 698      // Bail if activating from network, or bulk.
 699      if ( isset( $_GET['activate-multi'] ) ) {
 700          return;
 701      }
 702  
 703      // Record that this is a new installation, so we show the right
 704      // welcome message.
 705      if ( bp_is_install() ) {
 706          set_transient( '_bp_is_new_install', true, 30 );
 707      }
 708  
 709      // Add the transient to redirect.
 710      set_transient( '_bp_activation_redirect', true, 30 );
 711  }
 712  
 713  /** Signups *******************************************************************/
 714  
 715  /**
 716   * Check if the signups table needs to be created or upgraded.
 717   *
 718   * @since 2.0.0
 719   *
 720   * @global WPDB $wpdb
 721   */
 722  function bp_core_maybe_install_signups() {
 723      global $wpdb;
 724  
 725      // The table to run queries against.
 726      $signups_table = $wpdb->base_prefix . 'signups';
 727  
 728      // Suppress errors because users shouldn't see what happens next.
 729      $old_suppress  = $wpdb->suppress_errors();
 730  
 731      // Never use bp_core_get_table_prefix() for any global users tables.
 732      $table_exists  = (bool) $wpdb->get_results( "DESCRIBE {$signups_table};" );
 733  
 734      // Table already exists, so maybe upgrade instead?
 735      if ( true === $table_exists ) {
 736  
 737          // Look for the 'signup_id' column.
 738          $column_exists = $wpdb->query( "SHOW COLUMNS FROM {$signups_table} LIKE 'signup_id'" );
 739  
 740          // 'signup_id' column doesn't exist, so run the upgrade
 741          if ( empty( $column_exists ) ) {
 742              bp_core_upgrade_signups();
 743          }
 744  
 745      // Table does not exist, and we are a single site, so install the multisite
 746      // signups table using WordPress core's database schema.
 747      } elseif ( ! is_multisite() ) {
 748          bp_core_install_signups();
 749      }
 750  
 751      // Restore previous error suppression setting.
 752      $wpdb->suppress_errors( $old_suppress );
 753  }
 754  
 755  /** Activation Actions ********************************************************/
 756  
 757  /**
 758   * Fire activation hooks and events.
 759   *
 760   * Runs on BuddyPress activation.
 761   *
 762   * @since 1.6.0
 763   */
 764  function bp_activation() {
 765  
 766      // Force refresh theme roots.
 767      delete_site_transient( 'theme_roots' );
 768  
 769      // Add options.
 770      bp_add_options();
 771  
 772      /**
 773       * Fires during the activation of BuddyPress.
 774       *
 775       * Use as of 1.6.0.
 776       *
 777       * @since 1.6.0
 778       */
 779      do_action( 'bp_activation' );
 780  
 781      // @deprecated as of 1.6.0
 782      do_action( 'bp_loader_activate' );
 783  }
 784  
 785  /**
 786   * Fire deactivation hooks and events.
 787   *
 788   * Runs on BuddyPress deactivation.
 789   *
 790   * @since 1.6.0
 791   */
 792  function bp_deactivation() {
 793  
 794      // Force refresh theme roots.
 795      delete_site_transient( 'theme_roots' );
 796  
 797      // Switch to WordPress's default theme if current parent or child theme
 798      // depend on bp-default. This is to prevent white screens of doom.
 799      if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) ) {
 800          switch_theme( WP_DEFAULT_THEME, WP_DEFAULT_THEME );
 801          update_option( 'template_root',   get_raw_theme_root( WP_DEFAULT_THEME, true ) );
 802          update_option( 'stylesheet_root', get_raw_theme_root( WP_DEFAULT_THEME, true ) );
 803      }
 804  
 805      /**
 806       * Fires during the deactivation of BuddyPress.
 807       *
 808       * Use as of 1.6.0.
 809       *
 810       * @since 1.6.0
 811       */
 812      do_action( 'bp_deactivation' );
 813  
 814      // @deprecated as of 1.6.0
 815      do_action( 'bp_loader_deactivate' );
 816  }
 817  
 818  /**
 819   * Fire uninstall hook.
 820   *
 821   * Runs when uninstalling BuddyPress.
 822   *
 823   * @since 1.6.0
 824   */
 825  function bp_uninstall() {
 826  
 827      /**
 828       * Fires during the uninstallation of BuddyPress.
 829       *
 830       * @since 1.6.0
 831       */
 832      do_action( 'bp_uninstall' );
 833  }


Generated: Thu Sep 19 01:01:39 2019 Cross-referenced by PHPXref 0.7.1