/** * Displays the profile fields for both the public and private views. * * @since 1.0.0 * * @param arr $user_id optional. User id integer -- if not present, the function won't * attempt to fill in the data. * * @return html formatted profile fields. */ function bbconnect_profile_user_meta($args = '') { // SET THE DEFAULTS TO BE OVERRIDDEN AS DESIRED $defaults = array('user_id' => '', 'bbconnect_cap' => '', 'group_override' => false, 'action' => false, 'bbconnect_user_meta' => get_option('_bbconnect_user_meta'), 'post_arr' => false); // PARSE THE INCOMING ARGS $args = wp_parse_args($args, $defaults); // EXTRACT THE VARIABLES extract($args, EXTR_SKIP); // EXAMINE THE DISPLAY GRID if (isset($bbconnect_user_meta['column_2']) && !empty($bbconnect_user_meta['column_2'])) { $column_two = true; $column_one = ''; } else { $column_one = ' style="width: 99%;"'; } // IF WE HAVE POST VARS, FLATTEN THE ARRAY FOR PROCESSING if (false != $post_arr) { foreach ($post_arr as $key => $val) { if ('bbconnect_user_meta' == $key) { foreach ($val as $pkey => $pval) { $post_vars[$pkey] = $pval; } } else { $post_vars[$key] = $val; } } } ?> <div class="bbconnect-fields"> <div id="column_1_holder"<?php echo $column_one; ?> > <ul id="column_1"> <?php foreach ($bbconnect_user_meta['column_1'] as $key => $value) { // GET THE OPTION $user_meta = bbconnect_get_option($value); $args = array('meta' => $user_meta, 'bbconnect_cap' => $bbconnect_cap, 'group_override' => $group_override, 'action' => $action); $hide_meta = bbconnect_hide_meta($args); if ($hide_meta) { continue; } $post_val = false; if (isset($post_vars)) { // FOR SECTIONS & GROUPS if (in_array($user_meta['options']['field_type'], array('group', 'section'))) { $post_val = $post_vars; } else { if (isset($post_vars[$user_meta['meta_key']])) { $post_val = $post_vars[$user_meta['meta_key']]; } } } bbconnect_get_field(array('meta' => $user_meta, 'id' => $user_id, 'bbconnect_cap' => $bbconnect_cap, 'action' => $action, 'type' => 'user', 'post_val' => $post_val)); } ?> </ul> </div> <?php if (isset($column_two)) { ?> <div id="column_2_holder"> <ul id="column_2"> <?php foreach ($bbconnect_user_meta['column_2'] as $key => $value) { // GET THE OPTION $user_meta = bbconnect_get_option($value); $args = array('meta' => $user_meta, 'bbconnect_cap' => $bbconnect_cap, 'group_override' => $group_override, 'action' => $action); $hide_meta = bbconnect_hide_meta($args); if ($hide_meta) { continue; } $post_val = false; if (isset($post_vars)) { // FOR SECTIONS & GROUPS if (in_array($user_meta['options']['field_type'], array('group', 'section'))) { $post_val = $post_vars; } else { if (isset($post_vars[$user_meta['meta_key']])) { $post_val = $post_vars[$user_meta['meta_key']]; } } } bbconnect_get_field(array('meta' => $user_meta, 'id' => $user_id, 'bbconnect_cap' => $bbconnect_cap, 'action' => $action, 'type' => 'user', 'post_val' => $post_val)); } ?> </ul> </div> <?php } ?> </div> <?php }
function bbconnect_field($meta, $args = array()) { // CORNERSHOP CREATIVE CUSTOMIZATION $meta = apply_filters('bbconnect_field_prepare', $meta, $args); // EXTRACT THE VARIABLES extract($args, EXTR_SKIP); // FOR CONVENIENCE $key = $meta['meta_key']; $disabled = bbconnect_field_disabled($key); // SETUP THE LOGIC switch ($meta['options']['field_type']) { case 'title': // BUMP echo '<h3 class="bbconnect-section">' . stripslashes($meta['name']) . '</h3>'; if (isset($meta['description']) && !empty($meta['description'])) { echo '<p>' . $meta['description'] . '</p>'; } break; case 'taxonomy': $tax = $key; $taxonomy = get_taxonomy($tax); // DETERMINE WHETHER OR NOT CHILDREN ARE DISPLAYED if (isset($meta['options']['children']) && false == $meta['options']['children']) { $children = '&parent=0'; } else { $children = ''; } // SET THE DISPLAY OPTIONS if (isset($meta['options']['sort_by']) && false == $meta['options']['sort_by']) { $sort = '&orderby=name'; } else { $sort = '&orderby=id'; } $terms = get_terms($tax, 'hide_empty=0' . $sort . $children); if ('-view' == $action) { foreach ($terms as $term) { if (!empty($value) && in_array_r($term->term_id, $value)) { $output_arr[] = $term->name; } } if (!empty($output_arr)) { echo '<div> ' . implode(', ', $output_arr) . '</div>'; } } else { $display = get_option('_bbconnect_taxonomy_display'); // LET THE API OVERRIDE THIS if (isset($meta['options']['display'])) { $display = $meta['options']['display']; } if ('select' == $display || '-search' == $action) { echo '<select class="chzn-select" multiple="multiple" name="' . $name . '[]" style="width: 200px">'; $child_terms = array(); if ('' == $children) { foreach ($terms as $term) { $selected = ''; if (false != $term->parent) { if (!empty($value) && in_array_r($term->term_id, $value)) { $selected = ' selected'; } $child_terms[$term->parent][] = '<option value="' . $term->term_id . '"' . $selected . '> ' . $term->name . '</option>'; } } } foreach ($terms as $term) { $selected = ''; if (false != $term->parent) { continue; } if (!empty($value) && in_array_r($term->term_id, $value)) { $selected = ' selected'; } echo '<option value="' . $term->term_id . '"' . $selected . '>' . $term->name . '</option>'; if (isset($child_terms[$term->term_id])) { foreach ($child_terms[$term->term_id] as $pk => $pv) { echo $pv; } } } echo '</select>'; } else { echo '<div class="taxonomy-panel">'; if ('' == $children) { foreach ($terms as $term) { $checked = ''; if (false != $term->parent) { if (!empty($value) && in_array_r($term->term_id, $value)) { $checked = ' checked'; } $child_terms[$term->parent][] = '<span class="float-checkbox"> <input type="checkbox" name="' . $name . '[]" value="' . $term->term_id . '"' . $checked . ' /> ' . $term->name . '</span>'; } } } foreach ($terms as $term) { $checked = ''; if (false != $term->parent) { continue; } if (!empty($value) && in_array_r($term->term_id, $value)) { $checked = ' checked'; } echo '<span class="float-checkbox"><input type="checkbox" name="' . $name . '[]" value="' . $term->term_id . '"' . $checked . ' /> ' . $term->name; if (isset($child_terms[$term->term_id])) { foreach ($child_terms[$term->term_id] as $pk => $pv) { echo $pv; } } echo '</span>'; } echo '</div>'; } if ('-edit' == $action) { echo '<input type="hidden" name="' . $name . '[]" value="" />'; } // SPECIAL CASES if ('-bulk-edit' == $action) { echo '<div style="clear: both; padding: 7px;"><input type="radio" name="bbconnect_user_taxonomy_options[' . $key . ']" value="append" checked="checked" /> ' . __('Append', 'bbconnect') . '<input type="radio" name="bbconnect_user_taxonomy_options[' . $key . ']" value="overwrite" /> ' . __('Overwrite', 'bbconnect') . '<input type="radio" name="bbconnect_user_taxonomy_options[' . $key . ']" value="remove" /> ' . __('Remove', 'bbconnect') . '</div>'; } if ('-edit' == $action && current_user_can('list_users')) { echo '<div class="end-of-float"><a href="' . get_bloginfo('wpurl') . '/wp-admin/edit-tags.php?taxonomy=' . $tax . '&TB_iframe=true&height=450&width=920" class="thickbox button-primary">' . __('Add terms', 'bbconnect') . '</a></div>'; } } break; case 'section': if ('-view' != $action || 'true' == get_option('bbconnectpanels_public_labels')) { echo '<h3>' . stripslashes($meta['name']) . '</h3>'; } echo '<ul>'; if (!empty($meta['options']['choices'])) { // THIS IS A PASS THROUGH FOR ANY SANITIZED POST VALS $child_vals = array(); if (isset($value) && is_array($value) && !empty($value)) { $child_vals = $value; } foreach ($meta['options']['choices'] as $skey => $sval) { // GET THE OPTION $smeta = bbconnect_get_option($sval); // CHECK TO SEE IF ANY FIELDS HAVE BEEN REMOVED FROM DISPLAY $grouped_hide = bbconnect_hide_meta(array('meta' => $smeta, 'bbconnect_cap' => $capabilities, 'action' => $action)); if ($grouped_hide) { continue; } $post_val = false; if (in_array($smeta['options']['field_type'], array('group'))) { $post_val = $child_vals; } else { if (isset($child_vals[$smeta['meta_key']])) { $post_val = $child_vals[$smeta['meta_key']]; } } // ECHO OUT THE FIELDS! bbconnect_get_field(array('meta' => $smeta, 'id' => $cid, 'action' => $action, 'type' => $type, 'post_val' => $post_val)); } } echo '</ul>'; break; case 'textarea': // ALLOW OPTIONS TO HAVE SOME PRESETS if (empty($value) && !empty($meta['options']['choices'])) { $value = $meta['options']['choices']; } if ('-view' == $action) { echo wpautop($value); } else { if ('-edit' == $action) { // ONLY DISPLAY THE TEXT AREA IF WE KNOW FOR SURE WE HAVE THE RIGHT RESOURCES if (isset($meta['options']['wp_editor']) && false != $meta['options']['wp_editor']) { // CORNERSHOP CREATIVE CUSTOMIZATION $html_value = utf8_encode(html_entity_decode($value)); wp_editor($html_value, $key, array('textarea_name' => $name)); } else { echo '<textarea ' . $disabled . ' name="' . $name . '" id="' . $id . '" class="' . $class . '">' . $value . '</textarea>'; } } else { echo '<textarea ' . $disabled . ' name="' . $name . '" id="' . $id . '" class="' . $class . '">' . $value . '</textarea>'; } } break; case 'select': case 'multiselect': if ('-view' == $action) { if ('wpr' == $meta['source'] && 'display_name' == $key) { echo $value->display_name; } else { echo $value; } } else { // OPTIONALLY ADD LOOKUPS if ('-search' == $action) { $autocomp = ' chzn-select'; $multiple = ' multiple="multiple" data-placeholder="' . __('All Options', 'bbconnect') . '" style="width: 150px"'; $name = $name . '[]'; } else { if ('multiselect' == $meta['options']['field_type']) { $autocomp = ' chzn-select'; $multiple = ' multiple="multiple"'; $name = $name . '[]'; } else { if ('address' == substr($key, 0, 7)) { if (false !== strpos($key, 'country')) { $multiple = ''; $autocomp = ' country-field'; } else { if (false !== strpos($key, 'state')) { $multiple = ''; $autocomp = ' state-province-field'; } else { $autocomp = ''; $multiple = ''; } } } else { $autocomp = ''; $multiple = ''; } } } if ('wpr' == $meta['source']) { if ('-search' == $action) { } else { if (isset($flag) && 'normalize' == $flag) { } else { $name = $key; } } } // LET'S HANDLE ROLES if ('wpr' == $meta['source'] && 'role' == $key) { echo '<select ' . $disabled . ' name="' . $name . '" id="' . $id . '" class="regular-text' . $class . $autocomp . '"' . $multiple . '>'; if (is_array($value)) { $user_role = $value; } else { //$user_roles = array_keys( $value->wp_capabilities ); //$user_role = array_shift( $user_roles ); $user_roles = array_intersect(array_values($value->roles), array_keys(get_editable_roles())); $user_role = array_shift($user_roles); } // print the full list of roles with the primary one selected. bbconnect_dropdown_roles($user_role); // print the 'no role' option. Make it selected if the user has no role yet. if ('-search' == $action) { echo '<option value="no_role">' . __('No role for this site') . '</option>'; } else { if ($user_role) { echo '<option value="">' . __('— No role for this site —') . '</option>'; } else { echo '<option value="" selected="selected">' . __('— No role for this site —') . '</option>'; } } echo '</select>'; // AND DISPLAY NAMES (ADDING A FEW OPTIONS ALONG THE WAY) } else { if ('wpr' == $meta['source'] && 'display_name' == $key) { if (is_user_logged_in() && !empty($value)) { $cuser = $value; echo '<select ' . $disabled . ' name="' . $name . '" id="' . $id . '" class="regular-text' . $class . $autocomp . '"' . $multiple . '>'; $public_display = array(); if (!empty($cuser->nickname)) { $public_display['display_nickname'] = $cuser->nickname; } if (!empty($cuser->user_login)) { $public_display['display_username'] = $cuser->user_login; } if (!empty($cuser->first_name)) { $public_display['display_firstname'] = $cuser->first_name; } if (!empty($cuser->last_name)) { $public_display['display_lastname'] = $cuser->last_name; } // FOR ORGS if (!empty($cuser->bbconnect_organization)) { $public_display['display_organization'] = $cuser->bbconnect_organization; } if (!empty($cuser->first_name) && !empty($cuser->last_name)) { // SETUP FORMAL VARS if (!empty($cuser->bbconnect_prefix)) { $m_pre = $cuser->bbconnect_prefix . ' '; } if (!empty($cuser->bbconnect_suffix)) { $m_suf = ' ' . $cuser->bbconnect_suffix; } if (!empty($cuser->bbconnect_middle_name)) { $m_mid = ' ' . $cuser->bbconnect_middle_name . ' '; } else { $m_mid = ' '; } $public_display['display_formal'] = $m_pre . $cuser->first_name . $m_mid . $cuser->last_name . $m_suf; $public_display['display_firstlast'] = $cuser->first_name . ' ' . $cuser->last_name; $public_display['display_lastfirst'] = $cuser->last_name . ' ' . $cuser->first_name; } if (!empty($cuser->display_name)) { if (!in_array($cuser->display_name, $public_display)) { // Only add this if it isn't duplicated elsewhere $public_display = array('display_displayname' => $cuser->display_name) + $public_display; } } $public_display = array_map('trim', $public_display); $public_display = array_unique($public_display); foreach ($public_display as $id => $item) { echo '<option id="' . $id . '"' . selected($cuser->display_name, $item) . '>' . $item . '</option>'; } echo '</select>'; } // EVERYTHING ELSE } else { if (!is_array($value)) { $value = html_entity_decode($value); // Hack to fix issue with "Mr & Mrs" } echo '<select ' . $disabled . ' name="' . $name . '" id="' . $id . '" class="regular-text' . $class . $autocomp . '"' . $multiple . '>'; if (empty($value) && isset($meta['options']['default'])) { $value = $meta['options']['default']; } $setext = ''; echo '<option value="">' . $setext . '</option>'; // IF THIS IS A REFERENCE TO A HELPER, PICK IT UP if (!is_array($meta['options']['choices'])) { $option_arr = call_user_func($meta['options']['choices']); } else { $option_arr = $meta['options']['choices']; } // IF THIS IS AN ASSOCIATIVE ARRAY, CREATE OPTION GROUPS foreach ($option_arr as $choices => $choice) { if (is_array($choice)) { $true_match = true; if (false !== strpos($meta['meta_key'], 'address_state_')) { $true_match = false; $address_number = substr($meta['meta_key'], -1); $user_country = get_user_meta($_GET['user_id'], 'bbconnect_address_country_' . $address_number, true); $countries = bbconnect_helper_country(); $country = array_key_exists($user_country, $countries) ? $countries[$user_country] : $user_country; if ($choices == $country) { $true_match = true; } } foreach ($choice as $topkey => $topvalue) { if (is_array($topvalue)) { echo '<optgroup label="' . $topkey . '">'; foreach ($topvalue as $subkey => $subvalue) { echo '<option value="' . $subkey . '"'; if (is_array($value)) { if (in_array($subkey, $value) && $true_match) { echo ' selected="selected"'; } } elseif ($true_match) { echo selected($value, $subkey); } echo '>' . $subvalue . '</option>'; } echo '</optgroup>'; } else { echo '<option value="' . $topkey . '"'; if (is_array($value)) { if (in_array($topkey, $value) && $true_match) { echo ' selected="selected"'; } } elseif ($true_match) { echo selected($value, $topkey); } echo '>' . $topvalue . '</option>'; } } } else { echo '<option value="' . $choices . '"'; if (is_array($value)) { if (in_array($choices, $value)) { echo ' selected="selected"'; } } else { echo selected($value, $choices); } echo '>' . $choice . '</option>'; } } echo '</select>'; } } } break; case 'checkbox': if ('-bulk-edit' == $action) { echo '<select ' . $disabled . ' name="' . $name . '">'; echo '<option value="true">' . __('yes', 'bbconnect') . '</option>'; echo '<option value="false">' . __('no', 'bbconnect') . '</option>'; echo '</select>'; } else { if ('-search' === $action) { echo '<select ' . $disabled . ' name="' . $name . '">'; echo '<option value=""' . selected($value, '') . '>' . __('empty', 'bbconnect') . '</option>'; echo '<option value="true"' . selected($value, 'true') . '>' . __('yes', 'bbconnect') . '</option>'; echo '<option value="false"' . selected($value, 'false') . '>' . __('no', 'bbconnect') . '</option>'; echo '</select>'; } else { if ('wp' == $meta['source']) { // SET THE DEFAULTS if ('true' === $meta['options']['choices']) { $chk = 'on'; $val = 'true'; } else { $chk = 'off'; $val = 'false'; } // LET THE USER SAVED VALUE OVERRIDE THE DEFAULTS if (!empty($value)) { if ('true' === $value) { $chk = 'on'; $val = 'true'; } else { $chk = 'off'; $val = 'false'; } } // SPECIAL CASE FOR THE ADMIN BARS AND SSL PREFERENCES if ('rich_editing' == $key || 'comment_shortcuts' == $key) { $wp_class = 'upt '; $wp_key = $key; $field_name = ' name="' . $key . '"'; } else { if ('show_admin_bar_front' == $key || 'show_admin_bar_admin' == $key || 'admin_bar_front' == $key) { $wp_key = 'admin_bar_front'; $wp_class = 'uwpt '; if ('on' == $chk) { $field_name = ' name="admin_bar_front"'; } else { $field_name = ''; } $val = 'true'; } else { $wp_key = $key; $wp_class = 'umt '; $field_name = ' name="' . $key . '"'; } } echo '<a class="' . $wp_class . $chk . $class . '" title="' . $wp_key . '"><input type="hidden" id="' . $wp_key . '"' . $field_name . ' value="' . $val . '" /> ' . $meta['name'] . '</a> '; } else { // SET THE DEFAULTS if ('true' === $meta['options']['choices']) { $chk = 'on'; $val = 'true'; } else { $chk = 'off'; $val = 'false'; } // LET THE USER SAVED VALUE OVERRIDE THE DEFAULTS if (!empty($value)) { if ('true' === $value) { $chk = 'on'; $val = 'true'; } else { $chk = 'off'; $val = 'false'; } } echo '<a class="upt ' . $chk . '" title="' . $title . '"><input type="hidden" id="' . $title . '" name="' . $name . '" value="' . $val . '" /> ' . $meta['name'] . '</a> '; } } } break; case 'radio': if ('-view' == $action) { echo $value; } else { // IF THIS IS A REFERENCE TO A HELPER, PICK IT UP if (!is_array($meta['options']['choices'])) { $option_arr = call_user_func($meta['options']['choices']); } else { $option_arr = $meta['options']['choices']; } echo '<ul>'; // IF THIS IS AN ASSOCIATIVE ARRAY, CREATE OPTION GROUPS foreach ($option_arr as $subkey => $subvalue) { if ('' != $value) { if ($subkey == $value) { $checked = ' checked'; } else { $checked = ''; } } else { $checked = ''; } echo '<li><input ' . $disabled . ' type="radio" name="' . $name . '" value="' . $subkey . '"' . $checked . ' /> ' . $subvalue . '</li>'; } echo '</ul>'; } break; case 'group': // THIS IS A PASS THROUGH FOR ANY SANITIZED POST VALS $child_vals = array(); if (isset($value) && is_array($value) && !empty($value)) { $child_vals = $value; } if ('-view' == $action) { foreach ($meta['options']['choices'] as $gkey => $gvalue) { // GET THE OPTION $gmeta = get_option($gvalue); $grouped_hide = bbconnect_hide_meta(array('meta' => $gmeta, 'bbconnect_cap' => $capabilities, 'action' => $action)); if ($grouped_hide) { continue; } $post_val = false; if (isset($child_vals[$gmeta['meta_key']])) { $post_val = $child_vals[$gmeta['meta_key']]; } bbconnect_get_field(array('meta' => $gmeta, 'id' => $cid, 'action' => $action, 'type' => $type, 'post_val' => $post_val)); } } else { $group_hide = bbconnect_hide_meta(array('meta' => $meta, 'group_override' => true, 'bbconnect_cap' => $capabilities, 'action' => $action)); if (false == $group_hide) { ?> <li> <div class="t-wrapper group"> <p class="t-trigger-wrapper group"> <span class="bbconnect-label group"> <span class="t-trigger group" title="<?php echo $id . $action; ?> "> <?php echo $meta['name']; ?> </span> </span> <span class="bbconnect-field"> <?php // LET PLUGINS EXTEND GROUPS do_action('bbconnect_group_markers', $meta, $cid, $action); ?> </span> </p> <div id="<?php echo $id . $action; ?> " class="t-panel"> <ul class="group-panel"> <?php foreach ($meta['options']['choices'] as $gkey => $gvalue) { // GET THE OPTION $gmeta = bbconnect_get_option($gvalue); $grouped_hide = bbconnect_hide_meta(array('meta' => $gmeta, 'bbconnect_cap' => $capabilities, 'action' => $action)); if ($grouped_hide) { continue; } $post_val = false; if (isset($child_vals[$gmeta['meta_key']])) { $post_val = $child_vals[$gmeta['meta_key']]; } bbconnect_get_field(array('meta' => $gmeta, 'id' => $cid, 'action' => $action, 'type' => $type, 'post_val' => $post_val)); } ?> </ul> </div> </div> </li> <?php } else { foreach ($meta['options']['choices'] as $gkey => $gvalue) { // GET THE OPTION $gmeta = bbconnect_get_option($gvalue); $grouped_hide = bbconnect_hide_meta(array('meta' => $gmeta, 'bbconnect_cap' => $capabilities, 'action' => $action)); if ($grouped_hide) { continue; } $post_val = false; if (isset($child_vals[$gmeta['meta_key']])) { $post_val = $child_vals[$gmeta['meta_key']]; } bbconnect_get_field(array('meta' => $gmeta, 'id' => $cid, 'action' => $action, 'type' => $type, 'post_val' => $post_val)); } } } break; case 'multitext': if ('-view' == $action) { $fdisplay = array(); if (is_array($value)) { foreach ($value as $fkey => $fval) { if (is_array($fval)) { $fdisplay[] = '<strong>' . $fval['type'] . ':</strong> ' . $fval['value']; } } } echo implode(', ', $fdisplay); } else { echo '<ul id="' . $id . '">'; //if ( is_array( $value ) && count( $value ) > 1 ) { // IF WE'RE JUST STARTING OUT WITH DATA, PREFILL THE VALUE ARRAY WITH NULLITY if (!is_array($value) || empty($value)) { $value = array(); // GO WITH OVERRIDES FIRST if (isset($meta['options']['add_fields']) && is_array($meta['options']['add_fields'])) { foreach ($meta['options']['add_fields'] as $k => $v) { $value[0][$k] = ''; } } $value[0]['value'] = ''; if (is_array($meta['options']['choices']) && !empty($meta['options']['choices'])) { $value[0]['type'] = ''; } } /* $single_val = ''; foreach( $value as $fkey => $fval ) { $single_val .= $value[$fkey]['value']; } */ $arrcount = count($value); $nfkey = 0; $key_type = ''; // COUNT THE FIELDS AVAILABLE $add_fields = false; $field_ct = 1; if (isset($meta['options']['add_fields']) && is_array($meta['options']['add_fields'])) { $add_fields = true; $field_ct = 1 + count($meta['options']['add_fields']); } $fper = round(52 / $field_ct); foreach ($value as $fkey => $fval) { // CREATE THE TYPE FROM THE OPTION // OPTIONALLY BYPASS THIS if (is_array($meta['options']['choices'])) { $arr_choices = array_filter($meta['options']['choices']); if (!empty($arr_choices)) { $key_type = '<select name="' . $name . '[' . $nfkey . '][type]" id="' . $id . '-' . $fkey . '-select">'; $key_type .= '<option value="">...</option>'; foreach ($meta['options']['choices'] as $typekey => $typeval) { $key_type .= '<option value="' . $typekey . '"'; if (isset($value[$fkey]['type'])) { $key_type .= selected($value[$fkey]['type'], $typekey, false); } $key_type .= '>' . $typeval . '</option>'; } $key_type .= '</select>'; } } if (false != $add_fields) { $add_fields = ''; foreach ($meta['options']['add_fields'] as $k => $v) { if (isset($value[$fkey][$k])) { $ctv = $value[$fkey][$k]; } else { $ctv = ''; } $add_name = $v['name']; if ('text' == $v['type']) { if (isset($v['class'])) { $tempclass = $class . ' ' . implode(' ', $v['class']); } $add_fields .= '<input type="text" name="' . $name . '[' . $nfkey . '][' . $k . ']" class="regular-text regular-multi' . $tempclass . '" style="width: ' . $fper . '%;" value="' . $ctv . '" placeholder="' . $add_name . '" /> '; } else { if ('checkbox' == $v['type']) { $chk = ''; if ('true' == $ctv) { $chk = 'on'; } $add_fields .= '<a class="upt ' . $chk . '" title="' . $k . '-' . $nfkey . '"><input type="hidden" id="' . $k . '-' . $nfkey . '" name="' . $name . '[' . $nfkey . '][' . $k . ']" value="' . $ctv . '" /> ' . $add_name . '</a> '; } } } } ?> <li id="<?php echo $id . '' . $fkey; ?> " class="multilist"> <?php /*<span class="handle"></span>*/ ?> <span> <?php echo $add_fields; ?> <input type="text" name="<?php echo $name . '[' . $nfkey . '][value]'; ?> " class="regular-text regular-multi<?php echo $class; ?> " style="width: <?php echo $fper; ?> %;" value="<?php echo $value[$fkey]['value']; ?> " placeholder="<?php _e('Value', 'bbconnect'); ?> " /> <?php echo $key_type; ?> </span> <?php if ($arrcount == 1) { ?> <a id="<?php echo $id . '' . $nfkey; ?> -sub" class="sub" title="<?php echo $nfkey; ?> " style="display:none;"> </a> <a id="<?php echo $id . '' . $nfkey; ?> -add" class="add" title="<?php echo $nfkey; ?> "> </a> <?php } else { if ($nfkey == $arrcount - 1) { ?> <a id="<?php echo $id . '' . $nfkey; ?> -sub" class="sub" title="<?php echo $nfkey; ?> "> </a> <a id="<?php echo $id . '' . $nfkey; ?> -add" class="add" title="<?php echo $nfkey; ?> "> </a> <?php } elseif ($nfkey == 0) { ?> <a id="<?php echo $id . '' . $nfkey; ?> -sub" class="sub" title="<?php echo $nfkey; ?> " style="display:none;"> </a> <?php } else { ?> <a class="sub" title="<?php echo $nfkey; ?> "> </a> <?php } } ?> </li> <?php $nfkey++; } /* } else { if ( !is_array( $value ) ) { $value = array(); } $single_val = ''; foreach( $value as $fkey => $fval ) { $single_val .= $value[$fkey]['value']; } if ( !isset( $fkey ) ) { $fkey = 0; } // CREATE THE TYPE FROM THE OPTION // OPTIONALLY BYPASS THIS if ( isset( $meta['options']['single_value'] ) ) { $key_type = ''; } else { $key_type = '<select name="'.$name.'[0][type]">'; $key_type .= '<option value="">...</option>'; foreach ( $meta['options']['choices'] as $typekey => $typeval ) { if ( is_array( $value ) && array_key_exists( $fkey, $value ) && isset( $value[$fkey]['type'] ) ) { $key_type .= '<option value="'.$typekey.'"'. selected( $value[$fkey]['type'], $typekey, false ) . '>'.$typeval.'</option>'; } else { $key_type .= '<option value="'.$typekey.'">'.$typeval.'</option>'; } } $key_type .= '</select>'; } if ( isset( $meta['options']['double_value'] ) ) { $dbl = '<input type="text" name="' . $name . '[0][label]" class="regular-text regular-multi' . $class . '" value="' . $value[$fkey]['label'] . '" /> '; } else { $dbl = false; } ?> <li id="<?php echo $id .''. $fkey; ?>" class="multilist"><span><?php echo $dbl; ?><input type="text" name="<?php echo $name . '[0][value]'; ?>" class="regular-text regular-multi<?php echo $class; ?>" value="<?php echo $single_val; ?>" /> <?php echo $key_type; ?></span> <a id="<?php echo $id .''. $fkey; ?>-sub" class="sub" title="<?php echo $fkey; ?>" style="display:none;"> </a> <a id="<?php echo $id .''. $fkey; ?>-add" class="add" title="0"> </a></li> <?php } */ echo '</ul>'; } break; case 'password': if ('-view' != $action) { echo '<ul>'; $choices = $meta['options']['choices']; if ('wpr' == $meta['source']) { ?> <li><input type="password" autocomplete="off" name="<?php echo $key . $choices[0]; ?> " id="<?php echo $key . $choices[0] . $action; ?> " class="regular-text<?php echo $class; ?> " value="" /> <?php _e('type password', 'bbconnect'); ?> </li> <li><input type="password" autocomplete="off" name="<?php echo $key . $choices[1]; ?> " id="<?php echo $key . $choices[1] . $action; ?> " class="regular-text<?php echo $class; ?> " value="" /> <?php _e('re-type password', 'bbconnect'); ?> </li> <?php } else { ?> <li><input type="password" autocomplete="off" name="<?php echo $name; ?> [<?php echo $choices[0]; ?> ]" id="<?php echo $key . $choices[0] . $action; ?> " class="regular-text<?php echo $class; ?> " value="" /> <?php _e('type password', 'bbconnect'); ?> </li> <li><input type="password" autocomplete="off" name="<?php echo $name; ?> [<?php echo $choices[1]; ?> ]" id="<?php echo $key . $choices[1] . $action; ?> " class="regular-text<?php echo $class; ?> " value="" /> <?php _e('re-type password', 'bbconnect'); ?> </li> <?php } echo '</ul>'; } break; case 'date': if ('wpr' == $meta['source']) { if ('-search' == $action) { } else { if (isset($flag) && 'normalize' == $flag) { } else { $name = $key; } } } if (is_array($value)) { $vds = $value[0]; $vde = $value[1]; } else { $vds = false; $vde = false; if ($disabled && !empty($value)) { $value = date('d F Y', strtotime($value)); } } if (!empty($vds) && is_real_date($vds) && $disabled) { $vds = date('d F Y', strtotime($vds)); } if (!empty($vde) && is_real_date($vde) && $disabled) { $vde = date('d F Y', strtotime($vde)); } if ('-search' == $action) { echo '<input ' . $disabled . ' type="text" name="' . $name . '[]" id="' . $id . '_start" placeholder="' . __('start', 'bbconnect') . '" class="regular-text bbconnect-date' . $class . '" value="' . $vds . '" />'; echo '<input ' . $disabled . ' type="text" name="' . $name . '[]" id="' . $id . '_end" placeholder="' . __('end', 'bbconnect') . '" class="regular-text bbconnect-date' . $class . '" value="' . $vde . '" />'; } else { echo '<input ' . $disabled . ' type="text" name="' . $name . '" id="' . $id . '" class="regular-text bbconnect-date' . $class . '" value="' . $value . '" />'; } break; case 'plugin': $args = array(); if ('user' == $type) { $args['fdata'] = get_userdata($cid); } else { if ('option' == $type) { $args['fdata'] = $meta; } else { if ('post' == $type) { $args['fdata'] = array('id' => $id, 'name' => $name, 'class' => $class); } } } $args['fvalue'] = $value; $args['faction'] = $action; $args['ftype'] = $type; $func = $meta['options']['choices']; call_user_func($func, $args); break; case 'number': case 'text': case 'hidden': // IF THIS IS A WORDPRESS USER FIELD, MAKE SOME SMALL MODIFICATIONS if ('wpr' == $meta['source']) { if (!empty($value) && is_object($value)) { if ('email' == $key || 'url' == $key) { $user_key = 'user_' . $key; } else { $user_key = $key; } $value = $value->{$user_key}; if ('user_registered' == $key && !empty($value)) { $value = date(get_option('date_format'), strtotime($value)); } } if ('-search' == $action) { } else { if (isset($flag) && 'normalize' == $flag) { } else { $name = $key; } } if ('-search' != $action) { if ('user_login' == $key && !empty($value)) { $disabled = ' disabled'; } if ('ID' == $key && !empty($value)) { $disabled = ' disabled'; } if ('user_registered' == $key && !empty($value)) { $disabled = ' disabled'; } } } // ALLOW OPTIONS TO HAVE SOME PRESETS if (empty($value) && !empty($meta['options']['choices'])) { $value = $meta['options']['choices']; } $field_type = $meta['options']['field_type']; $attr = ''; if ($field_type == 'number') { $align = 'right'; if ($meta['options']['is_currency'] && $value != '' && $disabled) { $field_type = 'text'; $value = '$' . number_format($value, 2); } $step = $meta['options']['is_currency'] ? '0.01' : '1'; $attr = ' step="' . $step . '"'; } else { $align = 'left'; } if ('-view' == $action) { if ('email' == $key) { echo '<a href="mailto:' . $value . '">' . $value . '</a>'; } else { if ('url' == $key) { echo '<a href="' . $value . '">' . $value . '</a>'; } else { echo $value; } } } else { if ($meta['options']['field_type'] != 'text') { echo '<input type="' . $field_type . '" name="' . $name . '" id="' . $id . '" class="regular-text' . $class . '" value="' . $value . '" style="text-align: ' . $align . ';" ' . $disabled . ' ' . $attr . '>'; } else { if ('-search' == $action && 'user_registered' == $key) { if (is_array($value)) { $vs = $value[0]; $ve = $value[1]; } else { $vs = false; $ve = false; } echo '<input type="text" name="' . $name . '[]" id="' . $id . '_start" placeholder="' . __('start', 'bbconnect') . '" class="regular-text bbconnect-date' . $class . '" value="' . $vs . '" />'; echo '<input type="text" name="' . $name . '[]" id="' . $id . '_end" placeholder="' . __('end', 'bbconnect') . '" class="regular-text bbconnect-date' . $class . '" value="' . $ve . '" />'; } else { if ('-search' == $action && 'ID' == $key) { echo '<input type="text" name="' . $name . '" id="' . $id . '" class="regular-text' . $class . '" value="' . $value . '"' . $disabled . ' />'; } else { if ('user_registered' == $key || 'ID' == $key) { echo $value . '<br />'; if ('ID' == $key) { echo implode('<br />', apply_filters('bbconnect_user_id_assets', array(), $value, $action)); } } else { if ('-search' == $action && is_array($value)) { echo '<input type="text" name="' . $name . '" id="' . $id . '" class="regular-text' . $class . '" value=""' . $disabled . ' />'; } else { echo '<input type="text" name="' . $name . '" id="' . $id . '" class="regular-text' . $class . '" value="' . $value . '"' . $disabled . ' />'; } } } } } } break; // EXTEND THE FIELD SYSTEM // EXTEND THE FIELD SYSTEM default: do_action('bbconnect_field_switch', $meta, $args); break; } }