/>

$component_page ) { if ( in_array( $component_id, array( 'register', 'activate' ), true ) ) { continue; } // Use the global value if a specific value hasn't been set. $component_value = isset( $saved_value[ $component_id ] ) ? $saved_value[ $component_id ] : $retval['global']; // Valid values are 'anyone' or 'memebers'. if ( ! in_array( $component_value, array( 'anyone', 'members' ), true ) ) { $component_value = $retval['global']; } $retval[ $component_id ] = $component_value; } return $retval; } /** * Form element to change the active template pack. */ function bp_admin_setting_callback_theme_package_id() { $options = ''; $package_id = bp_get_theme_package_id(); /* * Note: This should never be empty. /bp-templates/ is the * canonical backup if no other packages exist. If there's an error here, * something else is wrong. * * See BuddyPress::register_theme_packages() */ foreach ( (array) buddypress()->theme_compat->packages as $id => $theme ) { $options .= sprintf( '', esc_attr( $id ), selected( $theme->id, $package_id, false ), esc_html( $theme->name ) ); } // phpcs:disable WordPress.Security.EscapeOutput if ( $options ) : ?>

/> />

/> /> /> />

/>

Registration Settings pane:', 'buddypress' ); ?>

WP profile syncing field. * * @since 1.6.0 */ function bp_admin_setting_callback_profile_sync() { ?> /> />

/> /> /> />

$setting ) { $value = isset( $_POST[ $setting_name ] ) ? $_POST[ $setting_name ] : ''; bp_update_option( $setting_name, $value ); } } } // Some legacy options are not registered with the Settings API, or are reversed in the UI. $legacy_options = array( 'bp-disable-account-deletion', 'bp-disable-avatar-uploads', 'bp-disable-cover-image-uploads', 'bp-disable-group-avatar-uploads', 'bp-disable-group-cover-image-uploads', 'bp-disable-group-activity-deletions', 'bp_disable_blogforum_comments', 'bp-disable-profile-sync', 'bp_restrict_group_creation', 'hide-loggedout-adminbar', ); foreach ( $legacy_options as $legacy_option ) { // Note: Each of these options is represented by its opposite in the UI // Ie, the Profile Syncing option reads "Enable Sync", so when it's checked, // the corresponding option should be unset. $value = isset( $_POST[ $legacy_option ] ) ? '' : 1; bp_update_option( $legacy_option, $value ); } bp_core_redirect( add_query_arg( array( 'page' => 'bp-settings', 'updated' => 'true', ), bp_get_admin_url( 'admin.php' ) ) ); } } add_action( 'bp_admin_init', 'bp_core_admin_settings_save', 100 ); /** * Output settings API option. * * @since 1.6.0 * * @param string $option Form option to echo. * @param string $default_option Optional. Form option default. * @param bool $slug Optional. Form option slug. */ function bp_form_option( $option, $default_option = '', $slug = false ) { // phpcs:ignore WordPress.Security.EscapeOutput echo bp_get_form_option( $option, $default_option, $slug ); } /** * Return settings API option. * * @since 1.6.0 * * @param string $option Form option to return. * @param string $default_option Optional. Form option default. Default is empty string. * @param bool $slug Optional. Form option slug. Default is false. * @return string */ function bp_get_form_option( $option, $default_option = '', $slug = false ) { // Get the option and sanitize it. $value = bp_get_option( $option, $default_option ); // Slug? if ( true === $slug ) { /** * Filters the slug value in the form field. * * @since 1.6.0 * * @param string $value Value being returned for the requested option. * @param string $option Option whose value is being requested. */ $value = apply_filters( 'editable_slug', $value, $option ); } // Fallback to default. if ( empty( $value ) ) { $value = $default_option; } $value = esc_attr( $value ); /** * Filters the settings API option. * * @since 1.6.0 * * @param string $value Value being returned for the requested option. * @param string $option Option whose value is being requested. */ return apply_filters( 'bp_get_form_option', $value, $option ); }