| | 491 | |
| | 492 | /** |
| | 493 | * Add BuddyPress debug info to the WordPress Site Health info screen. |
| | 494 | * |
| | 495 | * @since 5.0.0 |
| | 496 | * |
| | 497 | * @param array $debug_info The Site's debug info. |
| | 498 | * @return array The Site's debug info, including the BuddyPress specific ones. |
| | 499 | */ |
| | 500 | function bp_core_admin_debug_information( $debug_info = array() ) { |
| | 501 | global $wp_settings_fields; |
| | 502 | $active_components = array_intersect_key( bp_core_get_components(), buddypress()->active_components ); |
| | 503 | $bp_settings = array(); |
| | 504 | |
| | 505 | foreach ( $wp_settings_fields['buddypress'] as $section => $settings ) { |
| | 506 | $prefix = ''; |
| | 507 | $component_id = str_replace( 'bp_', '', $section ); |
| | 508 | |
| | 509 | if ( isset( $active_components[ $component_id ]['title'] ) ) { |
| | 510 | $prefix = $active_components[ $component_id ]['title'] .': '; |
| | 511 | } |
| | 512 | |
| | 513 | foreach( $settings as $bp_setting ) { |
| | 514 | $reverse = ( |
| | 515 | strpos( $bp_setting['id'], 'hide' ) !== false || |
| | 516 | strpos( $bp_setting['id'], 'restrict' ) !== false || |
| | 517 | strpos( $bp_setting['id'], 'disable' ) !== false |
| | 518 | ); |
| | 519 | |
| | 520 | if ( ! isset( $bp_setting['id'] ) || '_bp_theme_package_id' === $bp_setting['id'] ) { |
| | 521 | continue; |
| | 522 | } |
| | 523 | |
| | 524 | $bp_setting_value = bp_get_option( $bp_setting['id'] ); |
| | 525 | if ( '0' === $bp_setting_value || '1' === $bp_setting_value ) { |
| | 526 | if ( ( $reverse && '0' === $bp_setting_value ) || ( ! $reverse && '1' === $bp_setting_value ) ) { |
| | 527 | $bp_setting_value = __( 'Yes', 'buddypress' ); |
| | 528 | } else { |
| | 529 | $bp_setting_value = __( 'No', 'buddypress' ); |
| | 530 | } |
| | 531 | } |
| | 532 | |
| | 533 | // Make sure to show the setting is reversed when site info is copied to clipboard. |
| | 534 | $bp_settings_id = $bp_setting['id']; |
| | 535 | if ( $reverse ) { |
| | 536 | $bp_settings_id = '! ' . $bp_settings_id; |
| | 537 | } |
| | 538 | |
| | 539 | $bp_settings[ $bp_settings_id ] = array( |
| | 540 | 'label' => $prefix . $bp_setting['title'], |
| | 541 | 'value' => $bp_setting_value, |
| | 542 | ); |
| | 543 | } |
| | 544 | } |
| | 545 | |
| | 546 | $debug_info['buddypress'] = array( |
| | 547 | 'label' => __( 'BuddyPress', 'buddypress' ), |
| | 548 | 'fields' => array_merge( |
| | 549 | array( |
| | 550 | 'version' => array( |
| | 551 | 'label' => __( 'Version', 'buddypress' ), |
| | 552 | 'value' => bp_get_version(), |
| | 553 | ), |
| | 554 | 'active_components' => array( |
| | 555 | 'label' => __( 'Active components', 'buddypress' ), |
| | 556 | 'value' => implode( wp_list_pluck( $active_components, 'title' ), ', ' ), |
| | 557 | ), |
| | 558 | 'template_pack' => array( |
| | 559 | 'label' => __( 'Active template pack', 'buddypress' ), |
| | 560 | 'value' => bp_get_theme_compat_name() . ' ' . bp_get_theme_compat_version(), |
| | 561 | ), |
| | 562 | ), |
| | 563 | $bp_settings |
| | 564 | ) |
| | 565 | ); |
| | 566 | |
| | 567 | return $debug_info; |
| | 568 | } |
| | 569 | add_filter( 'debug_information', 'bp_core_admin_debug_information' ); |