/>
/>
/>
/>
/>
/>
WP profile syncing field
*
* @since BuddyPress (1.6)
*
* @uses bp_form_option() To output the option value
*/
function bp_admin_setting_callback_profile_sync() {
?>
/>
/>
/>
$settings ) {
foreach( $settings as $setting_name => $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
$legacy_options = array(
'bp-disable-account-deletion',
'bp-disable-avatar-uploads',
'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 BuddyPress (1.6)
*
* @uses bp_get_bp_form_option()
*
* @param string $option
* @param string $default
* @param bool $slug
*/
function bp_form_option( $option, $default = '' , $slug = false ) {
echo bp_get_form_option( $option, $default, $slug );
}
/**
* Return settings API option
*
* @since BuddyPress (1.6)
*
* @uses bp_get_option()
* @uses esc_attr()
* @uses apply_filters()
*
* @param string $option
* @param string $default
* @param bool $slug
*/
function bp_get_form_option( $option, $default = '', $slug = false ) {
// Get the option and sanitize it
$value = bp_get_option( $option, $default );
// Slug?
if ( true === $slug )
$value = esc_attr( apply_filters( 'editable_slug', $value ) );
// Not a slug
else
$value = esc_attr( $value );
// Fallback to default
if ( empty( $value ) )
$value = $default;
// Allow plugins to further filter the output
return apply_filters( 'bp_get_form_option', $value, $option );
}