/** * Return the XProfile field visibility select list for settings. * * @since 2.0.0 * * @param array|string $args { * Args for the select list. * * @type int $field_id ID of the field to render. * @type string $before Markup to render before the field. * @type string $before_controls markup before form controls. * @type string $after Markup to render after the field. * @type string $after_controls Markup after the form controls. * @type string $class Class to apply to the field markup. * @type string $label_class Class to apply for the label element. * @type string $notoggle_tag Markup element to use for notoggle tag. * @type string $notoggle_class Class to apply to the notoggle element. * } * @return string $retval */ function bp_profile_get_settings_visibility_select($args = '') { // Parse optional arguments. $r = bp_parse_args($args, array('field_id' => bp_get_the_profile_field_id(), 'before' => '', 'before_controls' => '', 'after' => '', 'after_controls' => '', 'class' => 'bp-xprofile-visibility', 'label_class' => 'bp-screen-reader-text', 'notoggle_tag' => 'span', 'notoggle_class' => 'field-visibility-settings-notoggle'), 'xprofile_settings_visibility_select'); // Empty return value, filled in below if a valid field ID is found. $retval = ''; // Only do-the-do if there's a valid field ID. if (!empty($r['field_id'])) { // Start the output buffer. ob_start(); // Output anything before. echo $r['before']; ?> <?php if (bp_current_user_can('bp_xprofile_change_field_visibility')) { ?> <?php echo $r['before_controls']; ?> <label for="<?php echo esc_attr('field_' . $r['field_id']); ?> _visibility" class="<?php echo esc_attr($r['label_class']); ?> "><?php /* translators: accessibility text */ _e('Select visibility', 'buddypress'); ?> </label> <select class="<?php echo esc_attr($r['class']); ?> " name="<?php echo esc_attr('field_' . $r['field_id']); ?> _visibility" id="<?php echo esc_attr('field_' . $r['field_id']); ?> _visibility"> <?php foreach (bp_xprofile_get_visibility_levels() as $level) { ?> <option value="<?php echo esc_attr($level['id']); ?> " <?php selected($level['id'], bp_get_the_profile_field_visibility_level()); ?> ><?php echo esc_html($level['label']); ?> </option> <?php } ?> </select> <?php echo $r['after_controls']; ?> <?php } else { ?> <<?php echo esc_html($r['notoggle_tag']); ?> class="<?php echo esc_attr($r['notoggle_class']); ?> "><?php bp_the_profile_field_visibility_level_label(); ?> </<?php echo esc_html($r['notoggle_tag']); ?> > <?php } // Output anything after. echo $r['after']; // Get the output buffer and empty it. $retval = ob_get_clean(); } /** * Filters the dropdown list for setting visibility. * * @since 2.0.0 * * @param string $retval HTML output for the visibility dropdown list. * @param array $r Parsed arguments to be used with display. * @param array $args Original passed in arguments to be used with display. */ return apply_filters('bp_profile_settings_visibility_select', $retval, $r, $args); }
/** * Filter 'global' visibility levels from radio buttons. * * @since 1.0 * * @param string $retval * @param array $request * @param array $args * * @return array */ public function filter_global_visibility_from_radio_buttons($retval, $r, $args) { // Empty return value, filled in below if a valid field ID is found $retval = ''; // Only do-the-do if there's a valid field ID if (!empty($r['field_id'])) { // Start the output buffer ob_start(); // Output anything before echo $r['before']; ?> <?php if (bp_current_user_can('bp_xprofile_change_field_visibility')) { ?> <?php foreach (bp_xprofile_get_visibility_levels() as $level) { ?> <?php if ($level['id'] != 'global') { ?> <?php printf($r['before_radio'], esc_attr($level['id'])); ?> <label for="<?php echo esc_attr('see-field_' . $r['field_id'] . '_' . $level['id']); ?> "> <input type="radio" id="<?php echo esc_attr('see-field_' . $r['field_id'] . '_' . $level['id']); ?> " name="<?php echo esc_attr('field_' . $r['field_id'] . '_visibility'); ?> " value="<?php echo esc_attr($level['id']); ?> " <?php checked($level['id'], bp_get_the_profile_field_visibility_level()); ?> /> <span class="field-visibility-text"><?php echo esc_html($level['label']); ?> </span> </label> <?php echo $r['after_radio']; ?> <?php } ?> <?php } ?> <?php } // Output anything after echo $r['after']; // Get the output buffer and empty it $retval = ob_get_clean(); } return $retval; }
function rtmedia_api_process_bp_get_profile_request() { $this->rtmediajsonapifunction->rtmedia_api_verfiy_token(); //Errors $ec_no_fields = 400001; $msg_no_fields = __('no profile found', 'rtmedia'); $ec_profile_fields = 400002; $msg_profile_fields = __('profile fields', 'rtmedia'); $profile_fields = array(); $user_id = $loggedin_user_id = ''; extract($_REQUEST); if (empty($user_id)) { $user_id = $this->user_id; } else { $loggedin_user_id = $this->user_id; } $user = get_userdata($user_id); if (empty($user)) { echo $this->rtmedia_api_response_object('TRUE', $ec_no_fields, $msg_no_fields); exit; } $user_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id($user_id, 250, 250, 'full'); $profile_fields['id'] = $user_id; $profile_fields['avatar']['src'] = $user_data['avatar']; $profile_fields['avatar']['width'] = 250; $profile_fields['avatar']['height'] = 250; if (bp_has_profile(array('user_id' => $user_id))) { while (bp_profile_groups()) { bp_the_profile_group(); if (bp_profile_group_has_fields()) { while (bp_profile_fields()) { bp_the_profile_field(); if (bp_field_has_data()) { $profile_fields['fields'][bp_get_the_profile_field_name()] = array('value' => strip_tags(bp_get_the_profile_field_value()), 'privacy' => bp_get_the_profile_field_visibility_level()); } } } } } else { echo $this->rtmedia_api_response_object('FALSE', $ec_no_fields, $msg_no_fields); exit; } //If followers plugin exists if (function_exists('rtmedia_api_followers')) { $followers = rtmedia_api_followers($user_id); $following = rtmedia_api_following($user_id); foreach ($followers as $follower) { $follower_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id($follower, 66, 66); $profile_fields['follower'][] = array('id' => $follower, 'name' => $follower_data['name'], 'avatar' => $follower_data['avatar']); } foreach ($following as $follow) { $follow_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id($follow, 66, 66); $profile_fields['following'][] = array('id' => $follow, 'name' => $follow_data['name'], 'avatar' => $follow_data['avatar']); } } if (!empty($_REQUEST['user_id']) && $loggedin_user_id != $user_id) { $args = array('leader_id' => $user_id, 'follower_id' => $loggedin_user_id); if (function_exists('bp_follow_is_following')) { $profile_fields['loggedin_user']['following'] = 'FALSE'; if (bp_follow_is_following($args)) { $profile_fields['loggedin_user']['following'] = 'TRUE'; } $args = array('leader_id' => $loggedin_user_id, 'follower_id' => $user_id); $profile_fields['loggedin_user']['followed'] = 'FALSE'; if (bp_follow_is_following($args)) { $profile_fields['loggedin_user']['followed'] = 'TRUE'; } } } echo $this->rtmedia_api_response_object('TRUE', $ec_profile_fields, $msg_profile_fields, $profile_fields); exit; }
/** * Return the XProfile field visibility select list for settings * * @since BuddyPress (2.0.0) */ function bp_profile_get_settings_visibility_select($args = '') { // Parse optional arguments $r = bp_parse_args($args, array('field_id' => bp_get_the_profile_field_id(), 'before' => '', 'after' => '', 'class' => 'bp-xprofile-visibility'), 'xprofile_settings_visibility_select'); // Empty return value, filled in below if a valid field ID is found $retval = ''; // Only do-the-do if there's a valid field ID if (!empty($r['field_id'])) { // Start the output buffer ob_start(); // Output anything before echo $r['before']; ?> <?php if (bp_current_user_can('bp_xprofile_change_field_visibility')) { ?> <select class="<?php echo esc_attr($r['class']); ?> " name="<?php echo esc_attr('field_' . $r['field_id']); ?> _visibility"> <?php foreach (bp_xprofile_get_visibility_levels() as $level) { ?> <option value="<?php echo esc_attr($level['id']); ?> " <?php selected($level['id'], bp_get_the_profile_field_visibility_level()); ?> ><?php echo esc_html($level['label']); ?> </option> <?php } ?> </select> <?php } else { ?> <span class="field-visibility-settings-notoggle" title="<?php esc_attr_e("This field's visibility cannot be changed.", 'buddypress'); ?> "><?php bp_the_profile_field_visibility_level_label(); ?> </span> <?php } // Output anything after echo $r['after']; // Get the output buffer and empty it $retval = ob_get_clean(); } // Output the dropdown list return apply_filters('bp_profile_settings_visibility_select', $retval, $r, $args); }
/** * Return the field visibility radio buttons */ function bp_profile_get_visibility_radio_buttons() { $html = '<ul class="radio">'; foreach (bp_xprofile_get_visibility_levels() as $level) { $checked = $level['id'] == bp_get_the_profile_field_visibility_level() ? ' checked="checked" ' : ''; $html .= '<li><label for="see-field_' . esc_attr($level['id']) . '"><input type="radio" id="see-field_' . esc_attr($level['id']) . '" name="field_' . bp_get_the_profile_field_id() . '_visibility" value="' . esc_attr($level['id']) . '"' . $checked . ' /> ' . esc_html($level['label']) . '</label></li>'; } $html .= '</ul>'; return apply_filters('bp_profile_get_visibility_radio_buttons', $html); }
function rtmedia_api_process_bp_get_profile_request() { $this->rtmediajsonapifunction->rtmedia_api_verfiy_token(); //Errors $ec_no_fields = 400001; $msg_no_fields = esc_html__('no profile found', 'buddypress-media'); $ec_profile_fields = 400002; $msg_profile_fields = esc_html__('profile fields', 'buddypress-media'); $profile_fields = array(); $user_id = $loggedin_user_id = ''; $user_id = filter_input(INPUT_POST, 'user_id', FILTER_SANITIZE_NUMBER_INT); $loggedin_user_id = filter_input(INPUT_POST, 'loggedin_user_id', FILTER_SANITIZE_NUMBER_INT); if (empty($user_id)) { $user_id = $this->user_id; } else { $loggedin_user_id = $this->user_id; } $user = get_userdata($user_id); if (empty($user)) { wp_send_json($this->rtmedia_api_response_object('TRUE', $ec_no_fields, $msg_no_fields)); } $user_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id($user_id, 250, 250, 'full'); $profile_fields['id'] = $user_id; $profile_fields['avatar']['src'] = esc_url($user_data['avatar']); $profile_fields['avatar']['width'] = 250; $profile_fields['avatar']['height'] = 250; if (bp_has_profile(array('user_id' => $user_id))) { while (bp_profile_groups()) { bp_the_profile_group(); if (bp_profile_group_has_fields()) { while (bp_profile_fields()) { bp_the_profile_field(); if (bp_field_has_data()) { $profile_fields['fields'][bp_get_the_profile_field_name()] = array('value' => strip_tags(bp_get_the_profile_field_value()), 'privacy' => bp_get_the_profile_field_visibility_level()); } } } } } else { wp_send_json($this->rtmedia_api_response_object('FALSE', $ec_no_fields, $msg_no_fields)); } //If followers plugin exists if (function_exists('rtmedia_api_followers')) { $followers = rtmedia_api_followers($user_id); $following = $this->rtmediajsonapifunction->rtmedia_api_following($user_id); foreach ($followers as $follower) { $follower_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id($follower, 66, 66); $profile_fields['follower'][] = array('id' => $follower, 'name' => $follower_data['name'], 'avatar' => $follower_data['avatar']); } foreach ($following as $follow) { $follow_data = $this->rtmediajsonapifunction->rtmedia_api_user_data_from_id($follow, 66, 66); $profile_fields['following'][] = array('id' => $follow, 'name' => $follow_data['name'], 'avatar' => $follow_data['avatar']); } } if (!empty($user_id) && intval($loggedin_user_id) !== intval($user_id)) { $args = array('leader_id' => $user_id, 'follower_id' => $loggedin_user_id); if (function_exists('bp_follow_is_following')) { $profile_fields['loggedin_user']['following'] = 'FALSE'; if (bp_follow_is_following($args)) { $profile_fields['loggedin_user']['following'] = 'TRUE'; } $args = array('leader_id' => $loggedin_user_id, 'follower_id' => $user_id); $profile_fields['loggedin_user']['followed'] = 'FALSE'; if (bp_follow_is_following($args)) { $profile_fields['loggedin_user']['followed'] = 'TRUE'; } } } wp_send_json($this->rtmedia_api_response_object('TRUE', $ec_profile_fields, $msg_profile_fields, $profile_fields)); }
/** * Return the field visibility radio buttons */ function ez_bp_profile_get_visibility_radio_buttons($arr_args = '') { global $field; $arr_ev_levels_processed = $this->_arr_ev_levels_processed; $str_ev_level = $this->ez_bp_get_the_profile_field_visibility_level(); $str_field_edit = $arr_ev_levels_processed[$str_ev_level]['edit']; $str_field_viz = $arr_ev_levels_processed[$str_ev_level]['visible']; // Parse optional arguments $r = bp_parse_args($arr_args, array('field_id' => bp_get_the_profile_field_id(), 'before' => '<ul class="radio">', 'after' => '</ul>', 'before_radio' => '<li>', 'after_radio' => '</li>', 'class' => 'bp-xprofile-visibility'), 'xprofile_visibility_radio_buttons'); // Empty return value, filled in below if a valid field ID is found $retval = ''; // Only do-the-do if there's a valid field ID if (!empty($r['field_id'])) { // Start the output buffer ob_start(); // Output anything before echo $r['before']; ?> <?php if (bp_current_user_can('bp_xprofile_change_field_visibility')) { ?> <?php $str_label_needle = ':'; foreach (bp_xprofile_get_visibility_levels() as $level) { $str_edit = $this->get_level_edit($level['id']); $str_viz = $this->get_level_visible($level['id']); if ($str_edit == $str_field_edit) { echo $r['before_radio']; ?> <label for="<?php echo esc_attr('see-field_' . $r['field_id'] . '_' . $level['id']); ?> "> <input type="radio" id="<?php echo esc_attr('see-field_' . $r['field_id'] . '_' . $level['id']); ?> " name="<?php echo esc_attr('field_' . $r['field_id'] . '_visibility'); ?> " value="<?php echo esc_attr($level['id']); ?> " <?php checked($level['id'], bp_get_the_profile_field_visibility_level()); ?> /> <span class="field-visibility-text"><?php echo esc_html($this->ez_bp_get_the_profile_field_visibility_level_label($level['id'])); ?> </span> </label> <?php echo $r['after_radio']; } ?> <?php } ?> <?php } // Output anything after echo $r['after']; // Get the output buffer and empty it $retval = ob_get_clean(); } return apply_filters('bp_profile_get_visibility_radio_buttons', $retval, $r, $arr_args); }