[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-core/admin/ -> bp-core-admin-tools.php (source)

   1  <?php
   2  /**
   3   * BuddyPress Tools panel.
   4   *
   5   * @package BuddyPress
   6   * @subpackage Core
   7   * @since 2.0.0
   8   */
   9  
  10  // Exit if accessed directly.
  11  defined( 'ABSPATH' ) || exit;
  12  
  13  /**
  14   * Render the BuddyPress Tools page.
  15   *
  16   * @since 2.0.0
  17   */
  18  function bp_core_admin_tools() {
  19      ?>
  20      <div class="wrap">
  21  
  22          <h1 class="wp-heading-inline"><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h1>
  23          <hr class="wp-header-end">
  24  
  25          <p><?php esc_html_e( 'BuddyPress keeps track of various relationships between members, groups, and activity items.', 'buddypress' ); ?></p>
  26          <p><?php esc_html_e( 'Occasionally these relationships become out of sync, most often after an import, update, or migration.', 'buddypress' ); ?></p>
  27          <p><?php esc_html_e( 'Use the tools below to manually recalculate these relationships.', 'buddypress' ); ?>
  28          </p>
  29          <p class="attention"><?php esc_html_e( 'Some of these tools create substantial database overhead. Avoid running more than one repair job at a time.', 'buddypress' ); ?></p>
  30  
  31          <h2><?php esc_html_e( 'Activate checkboxe(s) to select the operation(s) to perform', 'buddypress' ); ?></h2>
  32  
  33          <form class="settings" method="post" action="">
  34  
  35              <fieldset>
  36                  <legend class="screen-reader-text"><?php esc_html_e( 'Repair tools', 'buddypress' ); ?></legend>
  37  
  38                  <?php foreach ( bp_admin_repair_list() as $item ) : ?>
  39                      <p>
  40                          <label for="<?php echo esc_attr( str_replace( '_', '-', $item[0] ) ); ?>">
  41                              <input type="checkbox" class="checkbox" name="<?php echo esc_attr( $item[0] ) . '" id="' . esc_attr( str_replace( '_', '-', $item[0] ) ); ?>" value="1" /> <?php echo esc_html( $item[1] ); ?>
  42                          </label>
  43                      </p>
  44                  <?php endforeach; ?>
  45  
  46                  <p class="submit">
  47                      <input class="button-primary" type="submit" name="bp-tools-submit" value="<?php esc_attr_e( 'Repair Items', 'buddypress' ); ?>" />
  48                      <?php wp_nonce_field( 'bp-do-counts' ); ?>
  49                  </p>
  50  
  51              </fieldset>
  52  
  53          </form>
  54  
  55      </div>
  56  
  57      <?php
  58  }
  59  
  60  /**
  61   * Handle the processing and feedback of the admin tools page.
  62   *
  63   * @since 2.0.0
  64   */
  65  function bp_admin_repair_handler() {
  66      if ( ! bp_is_post_request() || empty( $_POST['bp-tools-submit'] ) ) {
  67          return;
  68      }
  69  
  70      check_admin_referer( 'bp-do-counts' );
  71  
  72      // Bail if user cannot moderate.
  73      $capability = bp_core_do_network_admin() ? 'manage_network_options' : 'manage_options';
  74      if ( ! bp_current_user_can( $capability ) ) {
  75          return;
  76      }
  77  
  78      wp_cache_flush();
  79      $messages = array();
  80  
  81      foreach ( (array) bp_admin_repair_list() as $item ) {
  82          if ( isset( $item[2] ) && isset( $_POST[$item[0]] ) && 1 === absint( $_POST[$item[0]] ) && is_callable( $item[2] ) ) {
  83              $messages[] = call_user_func( $item[2] );
  84          }
  85      }
  86  
  87      if ( count( $messages ) ) {
  88          foreach ( $messages as $message ) {
  89              bp_admin_tools_feedback( $message[1] );
  90          }
  91      }
  92  }
  93  add_action( bp_core_admin_hook(), 'bp_admin_repair_handler' );
  94  
  95  /**
  96   * Get the array of the repair list.
  97   *
  98   * @return array
  99   */
 100  function bp_admin_repair_list() {
 101      $repair_list = array();
 102  
 103      // Members:
 104      // - member count
 105      // - last_activity migration (2.0).
 106      $repair_list[20] = array(
 107          'bp-total-member-count',
 108          __( 'Repair total members count.', 'buddypress' ),
 109          'bp_admin_repair_count_members',
 110      );
 111  
 112      $repair_list[25] = array(
 113          'bp-last-activity',
 114          __( 'Repair member "last activity" data.', 'buddypress' ),
 115          'bp_admin_repair_last_activity',
 116      );
 117  
 118      // Friends:
 119      // - user friend count.
 120      if ( bp_is_active( 'friends' ) ) {
 121          $repair_list[0] = array(
 122              'bp-user-friends',
 123              __( 'Repair total friends count for each member.', 'buddypress' ),
 124              'bp_admin_repair_friend_count',
 125          );
 126      }
 127  
 128      // Groups:
 129      // - user group count.
 130      if ( bp_is_active( 'groups' ) ) {
 131          $repair_list[10] = array(
 132              'bp-group-count',
 133              __( 'Repair total groups count for each member.', 'buddypress' ),
 134              'bp_admin_repair_group_count',
 135          );
 136      }
 137  
 138      // Blogs:
 139      // - user blog count.
 140      if ( bp_is_active( 'blogs' ) ) {
 141          $repair_list[90] = array(
 142              'bp-blog-records',
 143              __( 'Repopulate site tracking records.', 'buddypress' ),
 144              'bp_admin_repair_blog_records',
 145          );
 146  
 147          if ( bp_is_active( 'blogs', 'site-icon' ) ) {
 148              $repair_list[91] = array(
 149                  'bp-blog-site-icons',
 150                  __( 'Repair site tracking site icons/blog avatars synchronization.', 'buddypress' ),
 151                  'bp_admin_repair_blog_site_icons',
 152              );
 153          }
 154      }
 155  
 156      // Emails:
 157      // - reinstall emails.
 158      $repair_list[100] = array(
 159          'bp-reinstall-emails',
 160          __( 'Reinstall emails (delete and restore from defaults).', 'buddypress' ),
 161          'bp_admin_reinstall_emails',
 162      );
 163  
 164      // Invitations:
 165      // - maybe create the database table and migrate any existing group invitations.
 166      $repair_list[110] = array(
 167          'bp-invitations-table',
 168          __( 'Create the database table for Invitations and migrate existing group invitations if needed.', 'buddypress' ),
 169          'bp_admin_invitations_table',
 170      );
 171  
 172      ksort( $repair_list );
 173  
 174      /**
 175       * Filters the array of the repair list.
 176       *
 177       * @since 2.0.0
 178       *
 179       * @param array $repair_list Array of values for the Repair list options.
 180       */
 181      return (array) apply_filters( 'bp_repair_list', $repair_list );
 182  }
 183  
 184  /**
 185   * Recalculate friend counts for each user.
 186   *
 187   * @since 2.0.0
 188   *
 189   * @return array
 190   */
 191  function bp_admin_repair_friend_count() {
 192      global $wpdb;
 193  
 194      if ( ! bp_is_active( 'friends' ) ) {
 195          return;
 196      }
 197  
 198      /* translators: %s: the result of the action performed by the repair tool */
 199      $statement = __( 'Counting the number of friends for each user&hellip; %s', 'buddypress' );
 200      $result    = __( 'Failed!', 'buddypress' );
 201  
 202      $sql_delete = "DELETE FROM {$wpdb->usermeta} WHERE meta_key IN ( 'total_friend_count' );";
 203      if ( is_wp_error( $wpdb->query( $sql_delete ) ) ) {
 204          return array( 1, sprintf( $statement, $result ) );
 205      }
 206  
 207      $bp = buddypress();
 208  
 209      // Walk through all users on the site.
 210      $total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c;
 211  
 212      $updated = array();
 213      if ( $total_users > 0 ) {
 214          $per_query = 500;
 215          $offset = 0;
 216          while ( $offset < $total_users ) {
 217              // Only bother updating counts for users who actually have friendships.
 218              $friendships = $wpdb->get_results( $wpdb->prepare( "SELECT initiator_user_id, friend_user_id FROM {$bp->friends->table_name} WHERE is_confirmed = 1 AND ( ( initiator_user_id > %d AND initiator_user_id <= %d ) OR ( friend_user_id > %d AND friend_user_id <= %d ) )", $offset, $offset + $per_query, $offset, $offset + $per_query ) );
 219  
 220              // The previous query will turn up duplicates, so we
 221              // filter them here.
 222              foreach ( $friendships as $friendship ) {
 223                  if ( ! isset( $updated[ $friendship->initiator_user_id ] ) ) {
 224                      BP_Friends_Friendship::total_friend_count( $friendship->initiator_user_id );
 225                      $updated[ $friendship->initiator_user_id ] = 1;
 226                  }
 227  
 228                  if ( ! isset( $updated[ $friendship->friend_user_id ] ) ) {
 229                      BP_Friends_Friendship::total_friend_count( $friendship->friend_user_id );
 230                      $updated[ $friendship->friend_user_id ] = 1;
 231                  }
 232              }
 233  
 234              $offset += $per_query;
 235          }
 236      } else {
 237          return array( 2, sprintf( $statement, $result ) );
 238      }
 239  
 240      return array( 0, sprintf( $statement, __( 'Complete!', 'buddypress' ) ) );
 241  }
 242  
 243  /**
 244   * Recalculate group counts for each user.
 245   *
 246   * @since 2.0.0
 247   *
 248   * @return array
 249   */
 250  function bp_admin_repair_group_count() {
 251      global $wpdb;
 252  
 253      if ( ! bp_is_active( 'groups' ) ) {
 254          return;
 255      }
 256  
 257      /* translators: %s: the result of the action performed by the repair tool */
 258      $statement = __( 'Counting the number of groups for each user&hellip; %s', 'buddypress' );
 259      $result    = __( 'Failed!', 'buddypress' );
 260  
 261      $sql_delete = "DELETE FROM {$wpdb->usermeta} WHERE meta_key IN ( 'total_group_count' );";
 262      if ( is_wp_error( $wpdb->query( $sql_delete ) ) ) {
 263          return array( 1, sprintf( $statement, $result ) );
 264      }
 265  
 266      $bp = buddypress();
 267  
 268      // Walk through all users on the site.
 269      $total_users = $wpdb->get_row( "SELECT count(ID) as c FROM {$wpdb->users}" )->c;
 270  
 271      if ( $total_users > 0 ) {
 272          $per_query = 500;
 273          $offset = 0;
 274          while ( $offset < $total_users ) {
 275              // But only bother to update counts for users that have groups.
 276              $users = $wpdb->get_col( $wpdb->prepare( "SELECT user_id FROM {$bp->groups->table_name_members} WHERE is_confirmed = 1 AND is_banned = 0 AND user_id > %d AND user_id <= %d", $offset, $offset + $per_query ) );
 277  
 278              foreach ( $users as $user ) {
 279                  BP_Groups_Member::refresh_total_group_count_for_user( $user );
 280              }
 281  
 282              $offset += $per_query;
 283          }
 284      } else {
 285          return array( 2, sprintf( $statement, $result ) );
 286      }
 287  
 288      return array( 0, sprintf( $statement, __( 'Complete!', 'buddypress' ) ) );
 289  }
 290  
 291  /**
 292   * Recalculate user-to-blog relationships and useful blog meta data.
 293   *
 294   * @since 2.1.0
 295   *
 296   * @return array
 297   */
 298  function bp_admin_repair_blog_records() {
 299  
 300      /* translators: %s: the result of the action performed by the repair tool */
 301      $statement = __( 'Repopulating Blogs records&hellip; %s', 'buddypress' );
 302  
 303      // Default to failure text.
 304      $result    = __( 'Failed!',   'buddypress' );
 305  
 306      // Default to unrepaired.
 307      $repair    = false;
 308  
 309      // Run function if blogs component is active.
 310      if ( bp_is_active( 'blogs' ) ) {
 311          $repair = bp_blogs_record_existing_blogs();
 312      }
 313  
 314      // Setup success/fail messaging.
 315      if ( true === $repair ) {
 316          $result = __( 'Complete!', 'buddypress' );
 317      }
 318  
 319      // All done!
 320      return array( 0, sprintf( $statement, $result ) );
 321  }
 322  
 323  /**
 324   * Repair site icons/blog avatars synchronization.
 325   *
 326   * @since 7.0.0
 327   *
 328   * @return array
 329   */
 330  function bp_admin_repair_blog_site_icons() {
 331  
 332      /* translators: %s: the result of the action performed by the repair tool */
 333      $statement = __( 'Repairing site icons/blog avatars synchronization&hellip; %s', 'buddypress' );
 334  
 335      // Run function if blogs component is active.
 336      if ( bp_is_active( 'blogs', 'site-icon' ) ) {
 337          $blog_ids = get_sites(
 338              array(
 339                  'fields'   => 'ids',
 340                  'archived' => 0,
 341                  'mature'   => 0,
 342                  'spam'     => 0,
 343                  'deleted'  => 0,
 344              )
 345          );
 346  
 347          $sizes = array(
 348              array(
 349                  'key'  => 'site_icon_url_full',
 350                  'size' => bp_core_avatar_full_width(),
 351              ),
 352              array(
 353                  'key'  => 'site_icon_url_thumb',
 354                  'size' => bp_core_avatar_thumb_width(),
 355              ),
 356          );
 357  
 358          foreach ( $blog_ids as $blog_id ) {
 359              $site_icon = 0;
 360  
 361              foreach ( $sizes as $size ) {
 362                  $site_icon = bp_blogs_get_site_icon_url( $blog_id, $size['size'] );
 363                  if ( ! $site_icon ) {
 364                      $site_icon = 0;
 365                  }
 366  
 367                  bp_blogs_update_blogmeta( $blog_id, $size['key'], $site_icon );
 368              }
 369          }
 370      }
 371  
 372      // All done!
 373      return array( 0, sprintf( $statement, __( 'Complete!', 'buddypress' ) ) );
 374  }
 375  
 376  /**
 377   * Recalculate the total number of active site members.
 378   *
 379   * @since 2.0.0
 380   */
 381  function bp_admin_repair_count_members() {
 382      /* translators: %s: the result of the action performed by the repair tool */
 383      $statement = __( 'Counting the number of active members on the site&hellip; %s', 'buddypress' );
 384      delete_transient( 'bp_active_member_count' );
 385      bp_core_get_active_member_count();
 386      return array( 0, sprintf( $statement, __( 'Complete!', 'buddypress' ) ) );
 387  }
 388  
 389  /**
 390   * Repair user last_activity data.
 391   *
 392   * Re-runs the migration from usermeta introduced in BP 2.0.
 393   *
 394   * @since 2.0.0
 395   */
 396  function bp_admin_repair_last_activity() {
 397      /* translators: %s: the result of the action performed by the repair tool */
 398      $statement = __( 'Determining last activity dates for each user&hellip; %s', 'buddypress' );
 399      bp_last_activity_migrate();
 400      return array( 0, sprintf( $statement, __( 'Complete!', 'buddypress' ) ) );
 401  }
 402  
 403  /**
 404   * Create the invitations database table if it does not exist.
 405   * Migrate outstanding group invitations if needed.
 406   *
 407   * @since 6.0.0
 408   *
 409   * @return array
 410   */
 411  function bp_admin_invitations_table() {
 412      global $wpdb;
 413  
 414      require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
 415      require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
 416  
 417      /* translators: %s: the result of the action performed by the repair tool */
 418      $statement = __( 'Creating the Invitations database table if it does not exist&hellip; %s', 'buddypress' );
 419      $result    = __( 'Failed to create table!', 'buddypress' );
 420  
 421      bp_core_install_invitations();
 422  
 423      // Check for existence of invitations table.
 424      $table_name = BP_Invitation_Manager::get_table_name();
 425      $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) );
 426      if ( ! $wpdb->get_var( $query ) == $table_name ) {
 427          // Early return if table creation failed.
 428          return array( 2, sprintf( $statement, $result ) );
 429      } else {
 430          $result = __( 'Created invitations table!', 'buddypress' );
 431      }
 432  
 433      // Migrate group invitations if needed.
 434      if ( bp_is_active( 'groups' ) ) {
 435          $bp = buddypress();
 436  
 437          /* translators: %s: the result of the action performed by the repair tool */
 438          $migrate_statement = __( 'Migrating group invitations&hellip; %s', 'buddypress' );
 439          $migrate_result    = __( 'Failed to migrate invitations!', 'buddypress' );
 440  
 441          bp_groups_migrate_invitations();
 442  
 443          // Check that there are no outstanding group invites in the group_members table.
 444          $records = $wpdb->get_results( "SELECT id FROM {$bp->groups->table_name_members} WHERE is_confirmed = 0 AND is_banned = 0" );
 445          if ( empty( $records ) ) {
 446              $migrate_result = __( 'Migrated invitations!', 'buddypress' );
 447              return array( 0, sprintf( $statement . ' ' . $migrate_statement , $result, $migrate_result ) );
 448          } else {
 449              return array( 2, sprintf( $statement . ' ' . $migrate_statement , $result, $migrate_result ) );
 450          }
 451      }
 452  
 453      // Return a "create-only" success message.
 454      return array( 0, sprintf( $statement, $result ) );
 455  }
 456  
 457  /**
 458   * Assemble admin notices relating success/failure of repair processes.
 459   *
 460   * @since 2.0.0
 461   *
 462   * @param string      $message Feedback message.
 463   * @param string|bool $class   Unused.
 464   * @return false|Closure
 465   */
 466  function bp_admin_tools_feedback( $message, $class = false ) {
 467      if ( is_string( $message ) ) {
 468          $message = '<p>' . $message . '</p>';
 469          $class = $class ? $class : 'updated';
 470      } elseif ( is_wp_error( $message ) ) {
 471          $errors = $message->get_error_messages();
 472  
 473          switch ( count( $errors ) ) {
 474              case 0:
 475                  return false;
 476  
 477              case 1:
 478                  $message = '<p>' . $errors[0] . '</p>';
 479                  break;
 480  
 481              default:
 482                  $message = '<ul>' . "\n\t" . '<li>' . implode( '</li>' . "\n\t" . '<li>', $errors ) . '</li>' . "\n" . '</ul>';
 483                  break;
 484          }
 485  
 486          $class = $class ? $class : 'error';
 487      } else {
 488          return false;
 489      }
 490  
 491      $message = '<div id="message" class="' . esc_attr( $class ) . ' notice is-dismissible">' . $message . '</div>';
 492      $message = str_replace( "'", "\'", $message );
 493      $lambda  = function() use ( $message ) { echo $message; };
 494  
 495      add_action( bp_core_do_network_admin() ? 'network_admin_notices' : 'admin_notices', $lambda );
 496  
 497      return $lambda;
 498  }
 499  
 500  /**
 501   * Render the Available Tools page.
 502   *
 503   * We register this page on Network Admin as a top-level home for our
 504   * BuddyPress tools. This displays the default content.
 505   *
 506   * @since 2.0.0
 507   */
 508  function bp_core_admin_available_tools_page() {
 509      ?>
 510      <div class="wrap">
 511          <h1 class="wp-heading-inline"><?php esc_html_e( 'Tools', 'buddypress' ) ?></h1>
 512          <hr class="wp-header-end">
 513  
 514          <?php
 515  
 516          /**
 517           * Fires inside the markup used to display the Available Tools page.
 518           *
 519           * @since 2.0.0
 520           */
 521          do_action( 'bp_network_tool_box' ); ?>
 522  
 523      </div>
 524      <?php
 525  }
 526  
 527  /**
 528   * Render an introduction of BuddyPress tools on Available Tools page.
 529   *
 530   * @since 2.0.0
 531   */
 532  function bp_core_admin_available_tools_intro() {
 533      $query_arg = array(
 534          'page' => 'bp-tools'
 535      );
 536  
 537      $page = bp_core_do_network_admin() ? 'admin.php' : 'tools.php' ;
 538      $url  = add_query_arg( $query_arg, bp_get_admin_url( $page ) );
 539      ?>
 540      <div class="card tool-box">
 541          <h2><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h2>
 542          <p>
 543              <?php esc_html_e( 'BuddyPress keeps track of various relationships between users, groups, and activity items. Occasionally these relationships become out of sync, most often after an import, update, or migration.', 'buddypress' ); ?>
 544              <?php
 545              printf(
 546                  /* translators: %s: the link to the BuddyPress repair tools */
 547                  esc_html_x( 'Use the %s to repair these relationships.', 'buddypress tools intro', 'buddypress' ),
 548                  '<a href="' . esc_url( $url ) . '">' . esc_html__( 'BuddyPress Tools', 'buddypress' ) . '</a>'
 549              );
 550              ?>
 551          </p>
 552      </div>
 553      <?php
 554  }
 555  
 556  /**
 557   * Delete emails and restore from defaults.
 558   *
 559   * @since 2.5.0
 560   *
 561   * @return array
 562   */
 563  function bp_admin_reinstall_emails() {
 564      $switched = false;
 565  
 566      // Switch to the root blog, where the email posts live.
 567      if ( ! bp_is_root_blog() ) {
 568          switch_to_blog( bp_get_root_blog_id() );
 569          bp_register_taxonomies();
 570  
 571          $switched = true;
 572      }
 573  
 574      $emails = get_posts( array(
 575          'fields'           => 'ids',
 576          'post_status'      => 'publish',
 577          'post_type'        => bp_get_email_post_type(),
 578          'posts_per_page'   => 200,
 579          'suppress_filters' => false,
 580      ) );
 581  
 582      if ( $emails ) {
 583          foreach ( $emails as $email_id ) {
 584              wp_trash_post( $email_id );
 585          }
 586      }
 587  
 588      // Make sure we have no orphaned email type terms.
 589      $email_types = get_terms( bp_get_email_tax_type(), array(
 590          'fields'                 => 'ids',
 591          'hide_empty'             => false,
 592          'update_term_meta_cache' => false,
 593      ) );
 594  
 595      if ( $email_types ) {
 596          foreach ( $email_types as $term_id ) {
 597              wp_delete_term( (int) $term_id, bp_get_email_tax_type() );
 598          }
 599      }
 600  
 601      require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
 602      bp_core_install_emails();
 603  
 604      if ( $switched ) {
 605          restore_current_blog();
 606      }
 607  
 608      return array( 0, __( 'Emails have been successfully reinstalled.', 'buddypress' ) );
 609  }
 610  
 611  /**
 612   * Add notice on the "Tools > BuddyPress" page if more sites need recording.
 613   *
 614   * This notice only shows up in the network admin dashboard.
 615   *
 616   * @since 2.6.0
 617   */
 618  function bp_core_admin_notice_repopulate_blogs_resume() {
 619      $screen = get_current_screen();
 620      if ( 'tools_page_bp-tools-network' !== $screen->id ) {
 621          return;
 622      }
 623  
 624      if ( '' === bp_get_option( '_bp_record_blogs_offset' ) ) {
 625          return;
 626      }
 627  
 628      echo '<div class="error"><p>' . __( 'It looks like you have more sites to record. Resume recording by checking the "Repopulate site tracking records" option.', 'buddypress' ) . '</p></div>';
 629  }
 630  add_action( 'network_admin_notices', 'bp_core_admin_notice_repopulate_blogs_resume' );
 631  
 632  /**
 633   * Add BuddyPress debug info to the WordPress Site Health info screen.
 634   *
 635   * @since 5.0.0
 636   *
 637   * @param  array $debug_info The Site's debug info.
 638   * @return array             The Site's debug info, including the BuddyPress specific ones.
 639   */
 640  function bp_core_admin_debug_information( $debug_info = array() ) {
 641      global $wp_settings_fields;
 642      $active_components = array_intersect_key( bp_core_get_components(), buddypress()->active_components );
 643      $bp_settings       = array();
 644  
 645      foreach ( $wp_settings_fields['buddypress'] as $section => $settings ) {
 646          $prefix       = '';
 647          $component_id = str_replace( 'bp_', '', $section );
 648  
 649          if ( isset( $active_components[ $component_id ]['title'] ) ) {
 650              $prefix = $active_components[ $component_id ]['title'] .': ';
 651          }
 652  
 653          foreach( $settings as $bp_setting ) {
 654              $reverse = (
 655                  strpos( $bp_setting['id'], 'hide' ) !== false ||
 656                  strpos( $bp_setting['id'], 'restrict' ) !== false ||
 657                  strpos( $bp_setting['id'], 'disable' ) !== false
 658              );
 659  
 660              if ( ! isset( $bp_setting['id'] ) || '_bp_theme_package_id' === $bp_setting['id'] ) {
 661                  continue;
 662              }
 663  
 664              $bp_setting_value = bp_get_option( $bp_setting['id'] );
 665              if ( '0' === $bp_setting_value || '1' === $bp_setting_value ) {
 666                  if ( ( $reverse && '0' === $bp_setting_value ) || ( ! $reverse && '1' === $bp_setting_value ) ) {
 667                      $bp_setting_value = __( 'Yes', 'buddypress' );
 668                  } else {
 669                      $bp_setting_value = __( 'No', 'buddypress' );
 670                  }
 671              }
 672  
 673              // Make sure to show the setting is reversed when site info is copied to clipboard.
 674              $bp_settings_id = $bp_setting['id'];
 675              if ( $reverse ) {
 676                  $bp_settings_id = '! ' . $bp_settings_id;
 677              }
 678  
 679              $bp_settings[ $bp_settings_id ] = array(
 680                  'label' => $prefix . $bp_setting['title'],
 681                  'value' => $bp_setting_value,
 682              );
 683          }
 684      }
 685  
 686      $debug_info['buddypress'] = array(
 687          'label'  => __( 'BuddyPress', 'buddypress' ),
 688          'fields' => array_merge(
 689              array(
 690                  'version' => array(
 691                      'label' => __( 'Version', 'buddypress' ),
 692                      'value' => bp_get_version(),
 693                  ),
 694                  'active_components' => array(
 695                      'label' => __( 'Active components', 'buddypress' ),
 696                      'value' => implode( ', ', wp_list_pluck( $active_components, 'title' ) ),
 697                  ),
 698                  'template_pack' => array(
 699                      'label' => __( 'Active template pack', 'buddypress' ),
 700                      'value' => bp_get_theme_compat_name() . ' ' . bp_get_theme_compat_version(),
 701                  ),
 702              ),
 703              $bp_settings
 704          )
 705      );
 706  
 707      return $debug_info;
 708  }
 709  add_filter( 'debug_information', 'bp_core_admin_debug_information' );


Generated: Fri Nov 27 01:01:40 2020 Cross-referenced by PHPXref 0.7.1