*/ class UsersWP_Profile { /** * Prints the profile page header section. * * @since 1.0.0 * @package userswp * @param object $user The User ID. */ public function get_profile_header($user) { $banner = uwp_get_usermeta($user->ID, 'uwp_account_banner_thumb', ''); $avatar = uwp_get_usermeta($user->ID, 'uwp_account_avatar_thumb', ''); add_filter( 'upload_dir', 'uwp_handle_multisite_profile_image', 10, 1 ); $uploads = wp_upload_dir(); remove_filter( 'upload_dir', 'uwp_handle_multisite_profile_image' ); $upload_url = $uploads['baseurl']; if (is_user_logged_in() && get_current_user_id() == $user->ID && is_uwp_profile_page()) { $trigger_class = "uwp-profile-modal-form-trigger"; } else { $trigger_class = ""; } if (empty($banner)) { $banner = uwp_get_option('profile_default_banner', ''); if(empty($banner)){ $banner = USERSWP_PLUGIN_URL."/public/assets/images/banner.png"; } else { $banner = wp_get_attachment_url($banner); } } else { $banner = $upload_url.$banner; } if (empty($avatar)) { $avatar = get_avatar($user->user_email, 150); } else { // check the image is not a full url before adding the local upload url if (strpos($avatar, 'http:') === false && strpos($avatar, 'https:') === false) { $avatar = $upload_url.$avatar; } $avatar = ''; } ?>
ID), $user->ID).'" title="'.$user->display_name.'">'; } ?> '; } ?> ID) && is_uwp_profile_page()) { ?>
ID), $user->ID).'" title="'.$user->display_name.'">'; } ?>
ID) && is_uwp_profile_page()) { ?>
'; } ?>

display_name); ?> ID ); ?>

ID, 'uwp_account_bio', "" ); $bio = stripslashes($bio); $is_profile_page = is_uwp_profile_page(); if ($bio) { ?>
">
get_results("SELECT * FROM " . $table_name . " WHERE ( form_type = 'register' OR form_type = 'account' ) AND field_type = 'url' AND css_class LIKE '%uwp_social%' ORDER BY sort_order ASC"); if (is_uwp_profile_page()) { $show_type = '[profile_side]'; } elseif (is_uwp_users_page()) { $show_type = '[users]'; } else { $show_type = false; } if (!$show_type) { return; } ?>
'; } /** * Returns the custom fields content of profile page more info tab. * * @since 1.0.0 * @package userswp * @param object $user The User ID. * @return string More info tab content. */ public function get_profile_extra($user) { return $this->uwp_get_extra_fields($user, '[more_info]'); } /** * Returns the custom fields content of profile page sidebar. * * @since 1.0.0 * @package userswp * @param object $user The User ID. * @return string Sidebar custom fields content. */ public function get_profile_side_extra($user) { echo $this->uwp_get_extra_fields($user, '[profile_side]'); } /** * Returns the custom fields content of users page. * * @since 1.0.0 * @package userswp * @param object $user The User ID. * @return string Users page custom fields content. */ public function get_users_extra($user) { echo $this->uwp_get_extra_fields($user, '[users]'); } /** * Returns the custom fields content based on type. * * @since 1.0.0 * @package userswp * @param object $user The User ID. * @param string $show_type Filter type. * @return string Custom fields content. */ public function uwp_get_extra_fields($user, $show_type) { ob_start(); global $wpdb; $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; $fields = $wpdb->get_results("SELECT * FROM " . $table_name . " WHERE form_type = 'account' AND css_class NOT LIKE '%uwp_social%' ORDER BY sort_order ASC"); $wrap_html = false; if ($fields) { foreach ($fields as $field) { $show_in = explode(',',$field->show_in); if (!in_array($show_type, $show_in)) { continue; } if ($field->is_public == '0') { continue; } if ($field->is_public == '2') { $field_name = $field->htmlvar_name.'_privacy'; $val = uwp_get_usermeta($user->ID, $field_name, false); if ($val === 'no') { continue; } } $value = $this->uwp_get_field_value($field, $user); // Icon $icon = uwp_get_field_icon($field->field_icon); if ($field->field_type == 'fieldset') { $icon = ''; ?>

site_title; ?>

site_title; ?>:
htmlvar_name == 'uwp_account_bio') { $is_profile_page = is_uwp_profile_page(); $value = stripslashes($value); if ($value) { ?>
">
'; $wrapped_output .= $output; $wrapped_output .= '
'; } ob_end_clean(); return trim($wrapped_output); } /** * Returns enabled profile tabs * * @since 1.0.0 * @package userswp * @param object $user The User ID. * @return array Profile tabs */ public function get_profile_tabs($user) { $tabs = array(); // allowed tabs $allowed_tabs = uwp_get_option('enable_profile_tabs', array()); if (!is_array($allowed_tabs)) { $allowed_tabs = array(); } $extra = $this->get_profile_extra($user); if (in_array('more_info', $allowed_tabs) && $extra) { $tabs['more_info'] = array( 'title' => __( 'More Info', 'userswp' ), 'count' => $this->get_profile_count_icon($user) ); } if (in_array('posts', $allowed_tabs)) { $tabs['posts'] = array( 'title' => __( 'Posts', 'userswp' ), 'count' => uwp_post_count($user->ID, 'post') ); } if (in_array('comments', $allowed_tabs)) { $tabs['comments'] = array( 'title' => __( 'Comments', 'userswp' ), 'count' => uwp_comment_count($user->ID) ); } $all_tabs = apply_filters( 'uwp_profile_tabs', $tabs, $user, $allowed_tabs ); // order tabs as per option values if(!empty($allowed_tabs)){ $allowed_tabs = array_reverse($allowed_tabs); foreach($allowed_tabs as $key => $val){ if(isset($all_tabs[$val])){ $all_tabs = array($val => $all_tabs[$val]) + $all_tabs; } } } return $all_tabs; } /** * Prints the profile tab content template * * @since 1.0.0 * @package userswp * @param object $user The User ID. * @return void */ public function get_profile_tabs_content($user) { $tab = get_query_var('uwp_tab'); $account_page = uwp_get_page_id('account_page', false); $all_tabs = $this->get_profile_tabs($user); $tab_keys = array_keys($all_tabs); if (!empty($tab_keys)) { $default_key = $tab_keys[0]; } else { $default_key = false; } $active_tab = !empty( $tab ) && array_key_exists( $tab, $all_tabs ) ? $tab : $default_key; if (!$active_tab) { return; } ?>
ID); ?> ID) && $can_user_edit_account) { ?>
str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged') ), 'total' => $total, 'before_page_number' => ''.$translated.' ', 'type' => 'list' ) ); ?>
get_profile_extra($user); echo $extra; } /** * Prints the profile page "posts" tab content. * * @since 1.0.0 * @package userswp * @param object $user The User ID. * @return void */ public function get_profile_posts($user) { $allowed_tabs = uwp_get_option('enable_profile_tabs', array()); if (!is_array($allowed_tabs)) { $allowed_tabs = array(); } if (!in_array('posts', $allowed_tabs)) { return; } uwp_generic_tab_content($user, 'post', __('Posts', 'userswp')); } /** * Prints the profile page "comments" tab content. * * @since 1.0.0 * @package userswp * @param object $user The User ID. * @return void */ public function get_profile_comments($user) { $allowed_tabs = uwp_get_option('enable_profile_tabs', array()); if (!is_array($allowed_tabs)) { $allowed_tabs = array(); } if (!in_array('comments', $allowed_tabs)) { return; } ?>

ID); $maximum_pages = ceil($total_comments / $number); $args = array( 'number' => $number, 'offset' => $offset, 'author_email' => $user->user_email, 'paged' => $paged, 'post_type' => 'post', ); // The Query $the_query = new WP_Comment_Query(); $comments = $the_query->query( $args ); // The Loop if ($comments) { echo '
flush_rules( false ); delete_option('uwp_flush_rewrite'); } } } /** * Adds profile page query variables. * * @since 1.0.0 * @package userswp * @param array $query_vars Query variables. * @return array Modified Query variables array. */ public function profile_query_vars($query_vars) { $query_vars[] = 'uwp_profile'; $query_vars[] = 'uwp_tab'; $query_vars[] = 'uwp_subtab'; return $query_vars; } /** * Returns user profile link based on user id. * * @since 1.0.0 * @package userswp * @param string $link Unmodified link. * @param int $user_id User id. * @return string Modified link. */ public function get_profile_link($link, $user_id) { $page_id = uwp_get_page_id('profile_page', false); if ($page_id) { $link = get_permalink($page_id); } else { $link = ''; } if ($link != '') { if (isset($_REQUEST['page_id'])) { $permalink_structure = 'DEFAULT'; } else { $permalink_structure = 'CUSTOM'; // Add forward slash if not available $link = rtrim($link, '/') . '/'; } $url_type = apply_filters('uwp_profile_url_type', 'slug'); if ($url_type && 'id' == $url_type) { if ('DEFAULT' == $permalink_structure) { return add_query_arg(array('viewuser' => $user_id), $link); } else { return $link . $user_id; } } else { $user = get_userdata($user_id); if ( !empty($user->user_nicename) ) { $username = $user->user_nicename; } else { $username = $user->user_login; } if ('DEFAULT' == $permalink_structure) { return add_query_arg(array('username' => $username), $link); } else { return $link . $username; } } } else { return ''; } } /** * Modifies profile page title to include username. * * @since 1.0.0 * @package userswp * @param string $title Original title * @param int|null $id Page id. * @return string Modified page title. */ public function modify_profile_page_title( $title, $id = null ) { global $wp_query; $page_id = uwp_get_page_id('profile_page', false); if ($page_id == $id && isset($wp_query->query_vars['uwp_profile']) && in_the_loop()) { $url_type = apply_filters('uwp_profile_url_type', 'slug'); $author_slug = $wp_query->query_vars['uwp_profile']; if ($url_type == 'id') { $user = get_user_by('id', $author_slug); } else { $user = get_user_by('slug', $author_slug); } $title = $user->display_name; } return $title; } /** * Returns json content for image crop. * * @since 1.0.0 * @package userswp * @param string $image_url Image url * @param string $type popup type. Avatar or Banner * @return string Json */ public function uwp_image_crop_popup($image_url, $type) { add_filter( 'upload_dir', 'uwp_handle_multisite_profile_image', 10, 1 ); $uploads = wp_upload_dir(); remove_filter( 'upload_dir', 'uwp_handle_multisite_profile_image' ); $upload_url = $uploads['baseurl']; $upload_path = $uploads['basedir']; $image_path = str_replace($upload_url, $upload_path, $image_url); $image = apply_filters( 'uwp_'.$type.'_cropper_image', getimagesize( $image_path ) ); if ( empty( $image ) ) { return ""; } // Get avatar full width and height. if ($type == 'avatar') { $full_width = apply_filters('uwp_avatar_image_width', 150); $full_height = apply_filters('uwp_avatar_image_height', 150); } else { $full_width = apply_filters('uwp_banner_image_width', uwp_get_option('profile_banner_width', 1000)); $full_height = apply_filters('uwp_banner_image_height', 300); } $values = array( 'error' => '', 'image_url' => $image_url, 'uwp_popup_type' => $type, 'uwp_full_width' => $full_width, 'uwp_full_height' => $full_height, 'uwp_true_width' => $image[0], 'uwp_true_height' => $image[1], 'uwp_popup_content' => $this->uwp_image_crop_modal_html($type, $image_url, $full_width, $full_height), ); $json = json_encode($values); return $json; } /** * Initializes image crop js. * * @since 1.0.0 * @package userswp * @param object $user The User ID. */ public function uwp_image_crop_init($user) { if (is_user_logged_in()) { add_action( 'wp_footer', array($this,'uwp_modal_loading_html')); add_action( 'wp_footer', array($this,'uwp_modal_close_js')); if(is_admin()) { add_action('admin_footer', array($this, 'uwp_modal_loading_html')); add_action('admin_footer', array($this, 'uwp_modal_close_js')); } } } /** * Returns modal content loading html. * * @since 1.0.0 * @package userswp * @return string Modal loding html. */ public function uwp_modal_loading_html() { ob_start(); ?>

uwp_formatSizeUnits($files->uwp_get_max_upload_size($type)); ?>

uwp_array_search($subarray, $key, $value)); } } return $results; } /** * Modifies get_avatar function to use userswp avatar. * * @since 1.0.0 * @package userswp * @param string $avatar img tag value for the user's avatar. * @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash, * user email, WP_User object, WP_Post object, or WP_Comment object. * @param int $size Square avatar width and height in pixels to retrieve. * @param string $default URL for the default image or a default type. Accepts '404', 'retro', 'monsterid', * 'wavatar', 'indenticon','mystery' (or 'mm', or 'mysteryman'), 'blank', or 'gravatar_default'. * Default is the value of the 'avatar_default' option, with a fallback of 'mystery'. * @param string $alt Alternative text to use in the avatar image tag. Default empty. * @return string Modified img tag value */ public function uwp_modify_get_avatar( $avatar, $id_or_email, $size, $default, $alt, $args ) { $user = false; if ( is_numeric( $id_or_email ) ) { $id = (int) $id_or_email; $user = get_user_by( 'id' , $id ); } elseif ( is_object( $id_or_email ) ) { if ( ! empty( $id_or_email->user_id ) ) { $id = (int) $id_or_email->user_id; $user = get_user_by( 'id' , $id ); } } else { $user = get_user_by( 'email', $id_or_email ); } if ( $user && is_object( $user ) ) { $avatar_thumb = uwp_get_usermeta($user->data->ID, 'uwp_account_avatar_thumb', ''); if ( !empty($avatar_thumb) ) { add_filter( 'upload_dir', 'uwp_handle_multisite_profile_image', 10, 1 ); $uploads = wp_upload_dir(); remove_filter( 'upload_dir', 'uwp_handle_multisite_profile_image' ); $upload_url = $uploads['baseurl']; if (substr( $avatar_thumb, 0, 4 ) !== "http") { $avatar_thumb = $upload_url.$avatar_thumb; } $avatar = "{$alt}"; } else { $default = uwp_get_default_avatar_uri(); $args = get_avatar_data( $id_or_email, $args ); $url = $args['url']; $url = remove_query_arg('d', $url); $url = add_query_arg(array('d' => $default), $url); if ( ! $url || is_wp_error( $url ) ) { return $avatar; } $avatar = ''.$alt.''; } } return $avatar; } /** * Modified the comment author url to profile page link for loggedin users. * * @since 1.0.0 * @package userswp * @param string $link Original author link. * @return string Modified author link. */ public function uwp_get_comment_author_link($link) { global $comment; if ( !empty( $comment->user_id ) && !empty( get_userdata( $comment->user_id )->ID ) ) { $user = get_userdata( $comment->user_id ); $link = sprintf( '%s', uwp_build_profile_tab_url( $comment->user_id ), strip_tags( $user->display_name ) ); } return $link; } /** * Redirects /author page to /profile page. * * @since 1.0.0 * @package userswp * @return void */ public function uwp_redirect_author_page() { if ( is_author() && apply_filters( 'uwp_check_redirect_author_page', true ) ) { $id = get_query_var( 'author' ); $link = uwp_build_profile_tab_url( $id ); $link = apply_filters( 'uwp_redirect_author_page', $link, $id ); wp_redirect($link); exit; } } /** * Modifies "edit my profile" link in admin bar * * @since 1.0.0 * @package userswp * @param string $url The complete URL including scheme and path. * @param int $user_id The user ID. * @param string $scheme Scheme to give the URL context. Accepts 'http', 'https', 'login', * 'login_post', 'admin', 'relative' or null. * @return false|string Filtered url. */ public function uwp_modify_admin_bar_edit_profile_url( $url, $user_id, $scheme ) { // Makes the link to http://example.com/account if (!is_admin()) { $account_page = uwp_get_page_id('account_page', false); if ($account_page) { $account_page_link = get_permalink($account_page); $url = $account_page_link; } } return $url; } /** * Restrict the files display only to current users in media popup. * * @since 1.0.0 * @package userswp * @param object $wp_query Unmodified wp_query. * @return object Modified wp_query. */ public function uwp_restrict_attachment_display($wp_query) { if (!is_admin()) { if ( ! current_user_can( 'manage_options' ) ) { //$wp_query['author'] = get_current_user_id(); $wp_query->set( 'author', get_current_user_id() ); } } return $wp_query; } /** * Allow users to upload files who has upload capability. * * @since 1.0.0 * @package userswp * @param array $llcaps An array of all the user's capabilities. * @param array $caps Actual capabilities for meta capability. * @param array $args Optional parameters passed to has_cap(), typically object ID. * @param object $user The user object. * @return array User capabilities. */ public function allow_all_users_profile_uploads($llcaps, $caps, $args, $user) { $files = new UsersWP_Files(); if(isset($caps[0]) && $caps[0] =='upload_files' && $files->uwp_doing_upload() ){ $llcaps['upload_files'] = true; } return $llcaps; } /** * Validates file uploads and returns errors if found. * * @since 1.0.0 * @package userswp * @param string|bool $value Original value. * @param object $field Field info. * @param string $file_key Field key. * @param array $file_to_upload File data to upload. * @return string|WP_Error Returns original value if no erros. Else returns errors. */ public function uwp_handle_file_upload_error_checks($value, $field, $file_key, $file_to_upload) { if (in_array($field->htmlvar_name, array('uwp_avatar_file', 'uwp_banner_file'))) { if ($field->htmlvar_name == 'uwp_avatar_file') { $min_width = apply_filters('uwp_avatar_image_width', 150); $min_height = apply_filters('uwp_avatar_image_height', 150); } else { $min_width = apply_filters('uwp_banner_image_width', uwp_get_option('profile_banner_width', 1000)); $min_height = apply_filters('uwp_banner_image_height', 300); } $imagedetails = getimagesize( $file_to_upload['tmp_name'] ); $width = $imagedetails[0]; $height = $imagedetails[1]; if ( $width < $min_width) { return new WP_Error( 'image-too-small', sprintf( __( 'The uploaded file is too small. Minimum image width should be %s px', 'userswp' ), $min_width)); } if ( $height < $min_height) { return new WP_Error( 'image-too-small', sprintf( __( 'The uploaded file is too small. Minimum image height should be %s px', 'userswp' ), $min_height) ); } } return $value; } /** * Sets uwp_profile_upload to true on profile page. * * @since 1.0.0 * @package userswp * @param array $params Plupload params * @return array Plupload params */ public function add_uwp_plupload_param($params) { if(!is_admin() && get_the_ID()==uwp_get_page_id('profile_page', false)){ $params['uwp_profile_upload'] = true; } return $params; } /** * Handles avatar and banner file upload. * * @since 1.0.0 * @package userswp * @return void */ public function uwp_ajax_avatar_banner_upload() { // Image upload handler // todo: security checks $type = strip_tags(esc_sql($_POST['uwp_popup_type'])); if (!in_array($type, array('banner', 'avatar'))) { $result['error'] = uwp_wrap_notice(__("Invalid request!", "userswp"), 'error'); $return = json_encode($result); echo $return; die(); } global $wpdb; $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $table_name . " WHERE form_type = %s AND field_type = 'file' AND is_active = '1' ORDER BY sort_order ASC", array($type))); $field = false; if ($fields) { $field = $fields[0]; } $result = array(); if (!$field) { $result['error'] = uwp_wrap_notice(__("No fields available", "userswp"), 'error'); $return = json_encode($result); echo $return; die(); } $files = new UsersWP_Files(); $errors = $files->handle_file_upload($field, $_FILES); if (is_wp_error($errors)) { $result['error'] = uwp_wrap_notice($errors->get_error_message(), 'error'); $return = json_encode($result); echo $return; } else { $return = $this->uwp_ajax_image_crop_popup($errors['url'], $type); echo $return; } die(); } /** * Returns the avatar and banner crop popup html and js. * * @since 1.0.0 * @package userswp * @param string $image_url Image url to crop. * @param string $type Crop type. Avatar or Banner * @return string|null Html and js content. */ public function uwp_ajax_image_crop_popup($image_url, $type){ wp_enqueue_style( 'jcrop' ); wp_enqueue_script( 'jcrop', array( 'jquery' ) ); $output = null; if ($image_url && $type ) { $output = $this->uwp_image_crop_popup($image_url, $type); } return $output; } /** * Handles crop popup form ajax request. * * @since 1.0.0 * @package userswp * @return void */ public function uwp_ajax_image_crop_popup_form(){ $type = strip_tags(esc_sql($_POST['type'])); $output = null; if ($type && in_array($type, array('banner', 'avatar'))) { $output = $this->uwp_crop_submit_form($type); } echo $output; exit(); } /** * Defines javascript ajaxurl variable. * * @since 1.0.0 * @package userswp * @return void */ public function uwp_define_ajaxurl() { echo ''; } /** * Adds UsersWP serach form in Users page. * * @since 1.0.0 * @package userswp * @return void */ public function uwp_users_search() { ?> get_results("SELECT * FROM " . $table_name . " WHERE form_type = 'account' AND is_public != '0' AND show_in LIKE '%[own_tab]%' ORDER BY sort_order ASC"); $usermeta = uwp_get_usermeta_row($user->ID); $privacy = ! empty( $usermeta ) && $usermeta->user_privacy ? explode(',', $usermeta->user_privacy) : array(); foreach ($fields as $field) { if ($field->field_icon != '') { $icon = uwp_get_field_icon($field->field_icon); } else { $field_icon = uwp_field_type_to_fa_icon($field->field_type); if ($field_icon) { $icon = ''; } else { $icon = ''; } } $key = str_replace('uwp_account_', '', $field->htmlvar_name); if ($field->is_public == '1') { $tabs[$key] = array( 'title' => __($field->site_title, 'userswp'), 'count' => $icon ); } else { if (!in_array($field->htmlvar_name.'_privacy', $privacy)) { $tabs[$key] = array( 'title' => __($field->site_title, 'userswp'), 'count' => $icon ); } } } return $tabs; } /** * Prints custom field values as tab content. * * @since 1.0.0 * @package userswp * @param object $user The User ID. * @param string $active_tab Active tab. */ public function uwp_extra_fields_as_tab_values($user, $active_tab) { global $wpdb; $table_name = uwp_get_table_prefix() . 'uwp_form_fields'; $fields = $wpdb->get_results("SELECT * FROM " . $table_name . " WHERE form_type = 'account' AND is_public != '0' ORDER BY sort_order ASC"); $usermeta = uwp_get_usermeta_row($user->ID); $privacy = ! empty( $usermeta ) && $usermeta->user_privacy ? explode(',', $usermeta->user_privacy) : array(); $fieldsets = array(); $fieldset = false; foreach ($fields as $field) { $key = str_replace('uwp_account_', '', $field->htmlvar_name); if ($field->field_type == 'fieldset') { $fieldset = $key; } $show_in = explode(',',$field->show_in); if (in_array("[fieldset]", $show_in)) { $fieldsets[$fieldset][] = $field; } if ($key == $active_tab && $field->field_type != 'fieldset') { $value = $this->uwp_get_field_value($field, $user); echo '
'; echo $value; echo '
'; } } if (isset($fieldsets[$active_tab])) { $fieldset_fields = $fieldsets[$active_tab]; ?>
is_public == '1') { $display = true; } else { if (!in_array($field->htmlvar_name.'_privacy', $privacy)) { $display = true; } } if (!$display) { continue; } $value = $this->uwp_get_field_value($field, $user); // Icon $icon = uwp_get_field_icon( $field->field_icon ); ?>
site_title; ?>:
ID); $file_obj = new UsersWP_Files(); if ($field->htmlvar_name == 'uwp_account_email') { $value = $user_data->user_email; } elseif ($field->htmlvar_name == 'uwp_account_password') { $value = ''; $field->is_required = 0; } elseif ($field->htmlvar_name == 'uwp_account_confirm_password') { $value = ''; $field->is_required = 0; } else { $value = uwp_get_usermeta($user->ID, $field->htmlvar_name, ""); } // Select and Multiselect needs Value to be converted if ($field->field_type == 'select' || $field->field_type == 'multiselect') { $option_values_arr = uwp_string_values_to_options($field->option_values, true); // Select if ($field->field_type == 'select') { if($field->field_type_key != 'country'){ if (!empty($value)) { $data = $this->uwp_array_search($option_values_arr, 'value', $value); $value = $data[0]['label']; } else { $value = ''; } } } //Multiselect if ($field->field_type == 'multiselect' && !empty($value)) { if (!empty($value) && is_array($value)) { $array_value = array(); foreach ($value as $v) { if(!empty($v)){ $data = $this->uwp_array_search($option_values_arr, 'value', $v); $array_value[] = $data[0]['label']; } } if(!empty($array_value)){ $value = implode(', ', $array_value); }else{ $value = ''; } } else { $value = ''; } } } // Date if ($field->field_type == 'datepicker') { $extra_fields = unserialize($field->extra_fields); if ($extra_fields['date_format'] == '') $extra_fields['date_format'] = 'yy-mm-dd'; $date_format = $extra_fields['date_format']; if (!empty($value)) { $value = date('Y-m-d', $value); } $value = uwp_date($value, $date_format, 'Y-m-d'); } // Time if ($field->field_type == 'time') { $value = date(get_option('time_format'), strtotime($value)); } // URL if ($field->field_type == 'url' && !empty($value)) { $link_text = $value; // if deafult_value is not url then it will be used as link text. if ($field->default_value && !empty($field->default_value) ) { if (substr( $field->default_value, 0, 4 ) === "http") { $link_text = $value; } else { $link_text = $field->default_value; } } if (substr( $link_text, 0, 4 ) === "http") { $link_text = esc_url($link_text); } $value = ''.$link_text.''; } // Checkbox if ($field->field_type == 'checkbox') { if ($value == '1') { $value = 'Yes'; } else { $value = 'No'; } } // File if ($field->field_type == 'file') { $value = $file_obj->uwp_file_upload_preview($field, $value, false); } // Sanitize switch ($field->field_type) { case 'url': // already escaped break; case 'file': // already escaped break; case 'textarea': $value = esc_textarea( $value ); break; default: $value = esc_html( $value ); } if($field->field_type_key == 'country'){ $value = uwp_output_country_html($value); } return $value; } }