function cart_fields($get_fields_order, $key) { $order_field = ''; $cf = new Rcl_Custom_Fields(); foreach ((array) $get_fields_order as $custom_field) { $custom_field = apply_filters('custom_field_cart_form', $custom_field); if ($key == 'profile' && $custom_field['order'] != 1) { continue; } $slug = $custom_field['slug']; if ($custom_field['type'] == 'checkbox') { $chek = explode('#', $custom_field['field_select']); $count_field = count($chek); for ($a = 0; $a < $count_field; $a++) { $number_field++; $slug_chek = $slug . '_' . $a; $this->values[$key][$number_field]['chek'] = $slug_chek; } } else { if ($custom_field['type'] == 'agree') { $this->values[$key][$number_field]['chek'] = $slug; } else { if ($custom_field['type'] == 'radio') { $radio = explode('#', $custom_field['field_select']); $count_field = count($radio); for ($a = 0; $a < $count_field; $a++) { $number_field++; $slug_chek = $slug . '_' . $a; $this->values[$key][$number_field]['radio']['name'] .= $slug; $this->values[$key][$number_field]['radio']['id'] .= $slug_chek; } } else { $this->values[$key][$number_field]['other'] = $slug; } } } $requared = $custom_field['requared'] == 1 ? '<span class="required">*</span>' : ''; $val = isset($custom_field['value']) ? $custom_field['value'] : ''; $order_field .= '<tr>' . '<td><label>' . $cf->get_title($custom_field) . $requared . ':</label></td>' . '<td>' . $cf->get_input($custom_field, $val) . '</td>' . '</tr>'; $number_field++; } return $order_field; }
function rcl_custom_fields_regform($field) { $get_fields = get_option('custom_profile_field'); if ($get_fields) { $get_fields = stripslashes_deep($get_fields); $cf = new Rcl_Custom_Fields(); foreach ((array) $get_fields as $custom_field) { if ($custom_field['register'] != 1) { continue; } $custom_field = apply_filters('custom_field_regform', $custom_field); $class = isset($custom_field['class']) ? $custom_field['class'] : ''; $id = isset($custom_field['id']) ? 'id=' . $custom_field['id'] : ''; $attr = isset($custom_field['attr']) ? '' . $custom_field['attr'] : ''; $field .= '<div class="form-block-rcl ' . $class . '" ' . $id . ' ' . $attr . '>'; $star = $custom_field['requared'] == 1 ? ' <span class="required">*</span> ' : ''; $field .= '<label>' . $cf->get_title($custom_field) . $star . ''; if ($custom_field['type']) { $field .= ':'; } $field .= '</label>'; $field .= $cf->get_input($custom_field, $_POST[$custom_field['slug']]); $field .= '</div>'; } } return $field; }
function rcl_get_custom_fields_profile($user) { $get_fields = get_option('custom_profile_field'); $cf = new Rcl_Custom_Fields(); if ($get_fields) { $field = '<h3>Произвольные поля профиля:</h3> <table class="form-table">'; foreach ((array) $get_fields as $custom_field) { $slug = $custom_field['slug']; $meta = get_the_author_meta($slug, $user->ID); $field .= '<tr><th><label>' . $cf->get_title($custom_field) . ':</label></th>'; $field .= '<td>' . $cf->get_input($custom_field, $meta) . '</td>'; $field .= '</tr>'; } $field .= '</table>'; echo $field; } }
function rcl_get_list_custom_fields($post_id, $posttype = false, $id_form = false) { $get_fields = rcl_get_custom_fields($post_id, $posttype, $id_form); if (!$get_fields) { return false; } $public_fields = ''; $data = array('ID' => $post_id, 'post_type' => $posttype, 'form_id' => $id_form); $cf = new Rcl_Custom_Fields(); foreach ((array) $get_fields as $key => $custom_field) { if ($key === 'options') { continue; } $custom_field = apply_filters('custom_field_public_form', $custom_field, $data); $star = $custom_field['requared'] == 1 ? ' <span class="required">*</span> ' : ''; $postmeta = $post_id ? get_post_meta($post_id, $custom_field['slug'], 1) : ''; $public_fields .= '<tr><th><label>' . $cf->get_title($custom_field) . $star . ':</label></th>'; $public_fields .= '<td>' . $cf->get_input($custom_field, $postmeta) . '</td>'; $public_fields .= '</tr>'; } if (isset($public_fields)) { $public_fields = '<table>' . $public_fields . '</table>'; return $public_fields; } else { return false; } }