BP_REST_XProfile_Fields_Endpoint::get_socialnetworks_type_options( BP_XProfile_Field $field, array $request )
Get Social Network field options
Description
Parameters
- $field
-
(Required) XProfile field object.
- $request
-
(Required) request argument.
Return
(array)
Source
File: bp-xprofile/classes/class-bp-rest-xprofile-fields-endpoint.php
public function get_socialnetworks_type_options( $field, $request ) {
// Does option have children?
$options = $field->get_children();
if ( empty( $options ) ) {
$default_options = apply_filters(
'social_network_default_options',
array(
'facebook',
'twitter',
'linkedIn',
)
);
$all_options = bp_xprofile_social_network_provider();
$options = array();
if ( empty( $default_options ) ) {
$options = bp_xprofile_social_network_provider();
} else {
foreach ( $all_options as $opt ) {
if ( in_array( $opt->value, $default_options, true ) ) {
$options[] = $opt;
}
}
}
}
$providers = bp_xprofile_social_network_provider();
if ( ! empty( $options ) ) {
foreach ( $options as $k => $option ) {
$option->value = $option->name;
$key = bp_social_network_search_key( $option->name, $providers );
$option->name = $providers[ $key ]->name;
$option->icon = $providers[ $key ]->svg;
$options[ $k ] = $option;
}
}
return $options;
}
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.