Changeset 13728 for trunk/src/bp-core/admin/bp-core-admin-tools.php
- Timestamp:
- 02/16/2024 01:33:24 AM (2 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/admin/bp-core-admin-tools.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/admin/bp-core-admin-tools.php
r13680 r13728 757 757 function bp_core_admin_debug_information( $debug_info = array() ) { 758 758 global $wp_settings_fields; 759 $active_components = array_intersect_key( bp_core_get_components(), buddypress()->active_components ); 759 760 if ( ! bp_is_root_blog() ) { 761 return $debug_info; 762 } 763 764 $active_components = wp_list_pluck( bp_core_get_active_components( array(), 'objects' ), 'name', 'id' ); 760 765 $bp_settings = array(); 766 $skipped_settings = array( '_bp_theme_package_id', '_bp_community_visibility' ); 761 767 $bp_url_parsers = array( 762 768 'rewrites' => __( 'BP Rewrites API', 'buddypress' ), … … 772 778 } 773 779 774 775 780 foreach ( $wp_settings_fields['buddypress'] as $section => $settings ) { 776 781 $prefix = ''; 777 782 $component_id = str_replace( 'bp_', '', $section ); 778 783 779 if ( isset( $active_components[ $component_id ] ['title']) ) {780 $prefix = $active_components[ $component_id ] ['title'].': ';784 if ( isset( $active_components[ $component_id ] ) ) { 785 $prefix = $active_components[ $component_id ] .': '; 781 786 } 782 787 … … 788 793 ); 789 794 790 if ( ! isset( $bp_setting['id'] ) || '_bp_theme_package_id' === $bp_setting['id']) {795 if ( ! isset( $bp_setting['id'] ) || in_array( $bp_setting['id'], $skipped_settings, true ) ) { 791 796 continue; 792 797 } 793 798 794 $bp_setting_value = bp_get_option( $bp_setting['id'] ); 795 if ( '0' === $bp_setting_value || '1' === $bp_setting_value ) { 796 if ( ( $reverse && '0' === $bp_setting_value ) || ( ! $reverse && '1' === $bp_setting_value ) ) { 797 $bp_setting_value = __( 'Yes', 'buddypress' ); 799 $bp_setting_value = bp_get_option( $bp_setting['id'], 0 ); 800 801 if ( is_array( $bp_setting_value ) ) { 802 if ( is_numeric( key( $bp_setting_value ) ) ) { 803 $bp_setting_value = implode( ', ', $bp_setting_value ); 798 804 } else { 799 $bp_setting_value = __( 'No', 'buddypress' ); 805 $setting_array = $bp_setting_value; 806 $bp_setting_value = array(); 807 foreach ( $setting_array as $setting_array_key => $setting_array_value ) { 808 $bp_setting_value[ $setting_array_key ] = implode( ', ', $setting_array_value ); 809 } 810 } 811 } else { 812 $bp_setting_value = (int) $bp_setting_value; 813 if ( 0 === $bp_setting_value || 1 === $bp_setting_value ) { 814 if ( ( $reverse && 0 === $bp_setting_value ) || ( ! $reverse && 1 === $bp_setting_value ) ) { 815 $bp_setting_value = __( 'Yes', 'buddypress' ); 816 } else { 817 $bp_setting_value = __( 'No', 'buddypress' ); 818 } 800 819 } 801 820 } … … 814 833 } 815 834 835 $theme_settings = array(); 836 if ( current_theme_supports( 'buddypress' ) ) { 837 $theme_settings['standalone_bptheme'] = array( 838 'label' => __( 'BuddyPress standalone theme', 'buddypress' ), 839 'value' => wp_get_theme()->get( 'Name' ), 840 ); 841 } else { 842 $theme_settings['template_pack'] = array( 843 'label' => __( 'Active template pack', 'buddypress' ), 844 'value' => bp_get_theme_compat_name() . ' ' . bp_get_theme_compat_version(), 845 ); 846 } 847 816 848 $debug_info['buddypress'] = array( 817 849 'label' => __( 'BuddyPress', 'buddypress' ), 818 850 'fields' => array_merge( 819 851 array( 820 'version' => array(852 'version' => array( 821 853 'label' => __( 'Version', 'buddypress' ), 822 854 'value' => bp_get_version(), 823 855 ), 824 'active_components' => array(856 'active_components' => array( 825 857 'label' => __( 'Active components', 'buddypress' ), 826 'value' => implode( ', ', wp_list_pluck( $active_components, 'title' )),858 'value' => implode( ', ', $active_components ), 827 859 ), 828 'template_pack' => array( 829 'label' => __( 'Active template pack', 'buddypress' ), 830 'value' => bp_get_theme_compat_name() . ' ' . bp_get_theme_compat_version(), 831 ), 832 'url_parser' => array( 860 'url_parser' => array( 833 861 'label' => __( 'URL Parser', 'buddypress' ), 834 862 'value' => $bp_url_parser, 835 863 ), 864 'global_community_visibility' => array( 865 'label' => __( 'Community visibility', 'buddypress' ), 866 'value' => bp_get_community_visibility( 'global' ), 867 ), 836 868 ), 869 $theme_settings, 837 870 $bp_settings 838 871 ) … … 842 875 } 843 876 add_filter( 'debug_information', 'bp_core_admin_debug_information' ); 877 878 /** 879 * Adds a BuddyPress section to the Site Health Info Admin Screen help tabs. 880 * 881 * @since 14.0.0 882 */ 883 function bp_core_admin_debug_information_add_help_tab() { 884 if ( ! bp_is_root_blog() ) { 885 return; 886 } 887 888 if ( isset( $_REQUEST['tab'] ) && 'debug' === sanitize_key( wp_unslash( $_REQUEST['tab'] ) ) ) { 889 $screen = get_current_screen(); 890 891 $screen->add_help_tab( 892 array( 893 'id' => 'bp-debug-settings', 894 'title' => esc_html__( 'BuddyPress', 'buddypress' ), 895 'content' => bp_core_add_contextual_help_content( 'bp-debug-settings' ), 896 ) 897 ); 898 899 $help_sidebar = $screen->get_help_sidebar(); 900 $bp_links = sprintf( 901 '<p><a href="%1$s" class="bp-help-sidebar-links">%2$s</a></p>', 902 esc_url( 'https://buddypress.org/support/' ), 903 esc_html__( 'BuddyPress Support Forums', 'buddypress' ) 904 ); 905 906 $screen->set_help_sidebar( $help_sidebar . $bp_links ); 907 wp_add_inline_script( 908 'site-health', 909 '( function() { 910 let bpHelpSidebarLinks; 911 912 document.onreadystatechange = function() { 913 if ( document.readyState === "complete" ) { 914 bpHelpSidebarLinks = document.querySelector( \'.bp-help-sidebar-links\' ).closest( \'p\') 915 bpHelpSidebarLinks.style.display = \'none\'; 916 } 917 } 918 919 document.querySelectorAll( \'.contextual-help-tabs ul li a\' ).forEach( 920 function( a ) { 921 a.addEventListener( \'click\', function( e ) { 922 if ( \'tab-link-bp-debug-settings\' === e.target.parentElement.getAttribute( \'id\' ) ) { 923 bpHelpSidebarLinks.style.display = \'block\'; 924 } else { 925 bpHelpSidebarLinks.style.display = \'none\'; 926 } 927 } ); 928 } 929 ); 930 } )();' 931 ); 932 } 933 } 934 add_action( 'admin_head-site-health.php', 'bp_core_admin_debug_information_add_help_tab' );
Note: See TracChangeset
for help on using the changeset viewer.