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