function cp_formbuilder($results, $post = false) { global $cp_options; $custom_fields_array = array(); foreach ($results as $result) { // external plugins can modify or disable field $result = apply_filters('cp_formbuilder_field', $result, $post); if (!$result) { continue; } if (appthemes_str_starts_with($result->field_name, 'cp_')) { $custom_fields_array[] = $result->field_name; } $post_meta_val = $post ? get_post_meta($post->ID, $result->field_name, true) : false; ?> <li id="list_<?php echo esc_attr($result->field_name); ?> "> <div class="labelwrapper"> <label><?php echo esc_html(translate($result->field_label, APP_TD)); ?> <?php if ($result->field_req) { echo '<span class="colour">(*)</span>'; } ?> </label> </div> <?php $show_tooltip = !empty($result->field_tooltip); if ($show_tooltip) { echo html('a href="#" tip="' . esc_attr(translate($result->field_tooltip, APP_TD)) . '" tabindex="999"', html('div class="dashicons-before helpico"', ' ')); } else { } switch ($result->field_type) { case 'text box': if (isset($_POST[$result->field_name])) { $value = wp_kses_post(appthemes_clean($_POST[$result->field_name])); } elseif ($result->field_name == 'post_title' && $post) { $value = $post->post_title; } elseif ($result->field_name == 'tags_input' && $post) { $value = rtrim(trim(cp_get_the_term_list($post->ID, APP_TAX_TAG)), ','); } else { $value = $post_meta_val; } $field_class = $result->field_req ? 'text required' : 'text'; if ('cp_price' == $result->field_name && $cp_options->clean_price_field) { $field_class .= ' number'; } $field_minlength = empty($result->field_min_length) ? '0' : $result->field_min_length; $args = array('value' => $value, 'name' => $result->field_name, 'id' => $result->field_name, 'type' => 'text', 'class' => $field_class, 'minlength' => $field_minlength); $args = apply_filters('cp_formbuilder_' . $result->field_name, $args, $result, $post); echo html('input', $args); break; case 'drop-down': $options = explode(',', $result->field_values); $options = array_map('trim', $options); $html_options = ''; $html_options .= html('option', array('value' => ''), __('-- Select --', APP_TD)); foreach ($options as $option) { $args = array('value' => $option); if ($option == $post_meta_val) { $args['selected'] = 'selected'; } $args = apply_filters('cp_formbuilder_' . $result->field_name . '_option', $args, $result, $post); $html_options .= html('option', $args, $option); } $field_class = $result->field_req ? 'dropdownlist required' : 'dropdownlist'; $args = array('name' => $result->field_name, 'id' => $result->field_name, 'class' => $field_class); $args = apply_filters('cp_formbuilder_' . $result->field_name, $args, $result, $post); echo html('select', $args, $html_options); break; case 'text area': if (isset($_POST[$result->field_name])) { $value = wp_kses_post(appthemes_clean($_POST[$result->field_name])); } elseif ($result->field_name == 'post_content' && $post) { $value = $post->post_content; } else { $value = $post_meta_val; } $field_class = $result->field_req ? 'required' : ''; $field_minlength = empty($result->field_min_length) ? '15' : $result->field_min_length; $args = array('value' => $value, 'name' => $result->field_name, 'id' => $result->field_name, 'rows' => '8', 'cols' => '40', 'class' => $field_class, 'minlength' => $field_minlength); $args = apply_filters('cp_formbuilder_' . $result->field_name, $args, $result, $post); $value = $args['value']; unset($args['value']); if ($cp_options->allow_html && !wp_is_mobile()) { cp_editor($value, $args); } else { echo html('textarea', $args, esc_textarea($value)); } break; case 'radio': $options = explode(',', $result->field_values); $options = array_map('trim', $options); $html_radio = ''; $html_options = ''; if (!$result->field_req) { $args = array('value' => '', 'type' => 'radio', 'class' => 'radiolist', 'name' => $result->field_name, 'id' => $result->field_name); if (empty($post_meta_val)) { $args['checked'] = 'checked'; } $args = apply_filters('cp_formbuilder_' . $result->field_name, $args, $result, $post); $html_radio = html('input', $args) . ' ' . __('None', APP_TD); $html_options .= html('li', array(), $html_radio); } foreach ($options as $option) { $field_class = $result->field_req ? 'radiolist required' : 'radiolist'; $args = array('value' => $option, 'type' => 'radio', 'class' => $field_class, 'name' => $result->field_name, 'id' => $result->field_name); if ($option == $post_meta_val) { $args['checked'] = 'checked'; } $args = apply_filters('cp_formbuilder_' . $result->field_name, $args, $result, $post); $html_radio = html('input', $args) . ' ' . $option; $html_options .= html('li', array(), $html_radio); } echo html('ol', array('class' => 'radios'), $html_options); break; case 'checkbox': $post_meta_val = $post ? get_post_meta($post->ID, $result->field_name, false) : array(); $options = explode(',', $result->field_values); $options = array_map('trim', $options); $optionCursor = 1; $html_checkbox = ''; $html_options = ''; foreach ($options as $option) { $field_class = $result->field_req ? 'checkboxlist required' : 'checkboxlist'; $args = array('value' => $option, 'type' => 'checkbox', 'class' => $field_class, 'name' => $result->field_name . '[]', 'id' => $result->field_name . '_' . $optionCursor++); if (in_array($option, $post_meta_val)) { $args['checked'] = 'checked'; } $args = apply_filters('cp_formbuilder_' . $result->field_name, $args, $result, $post); $html_checkbox = html('input', $args) . ' ' . $option; $html_options .= html('li', array(), $html_checkbox); } echo html('ol', array('class' => 'checkboxes'), $html_options); break; } ?> </li> <?php echo html('div', array('class' => 'clr')); } // put all the custom field names into an hidden field so we can process them on save $custom_fields_vals = implode(',', $custom_fields_array); echo html('input', array('type' => 'hidden', 'name' => 'custom_fields_vals', 'value' => $custom_fields_vals)); cp_action_formbuilder($results, $post); }
function cp_formbuilder_buyer($results, $post = false) { global $wpdb, $cp_options; $custom_fields_array = array(); foreach ($results as $result) { // external plugins can modify or disable field $result = apply_filters('cp_formbuilder_field', $result, $post); // //var_dump($result); if (!$result) { continue; } if (appthemes_str_starts_with($result->field_name, 'cp_')) { $custom_fields_array[] = $result->field_name; } $post_meta_val = $post ? get_post_meta($post->ID, $result->field_name, true) : false; if ($result->field_name == 'post_content') { echo "</ol><ol>"; } ?> <li id="list_<?php echo esc_attr($result->field_name); ?> " <?php /*if($result->field_name=='post_title') echo 'style="display:none;"'; */ ?> > <?php /*?><div class="labelwrapper"> <label><?php if ( $result->field_tooltip ) { ?><a href="#" tip="<?php echo esc_attr( translate( $result->field_tooltip, APP_TD ) ); ?>" tabindex="999"><div class="helpico"></div></a><?php } ?><?php echo esc_html( translate( $result->field_label, APP_TD ) ); ?>: <?php if ( $result->field_req ) echo '<span class="colour">*</span>'; ?></label> <?php if ( ($result->field_type) == 'text area' && ( $cp_options->allow_html ) ) { // only show this for tinymce since it's hard to position the error otherwise ?> <br /><label class="invalid tinymce" for="<?php echo esc_attr($result->field_name); ?>"><?php _e( 'This field is required.', APP_TD ); ?></label> <?php } ?> </div><?php */ ?> <?php if ($result->field_name == 'cp_video_url') { continue; } switch ($result->field_type) { case 'text box': if (isset($_POST[$result->field_name])) { $value = wp_kses_post(appthemes_clean($_POST[$result->field_name])); } elseif ($result->field_name == 'post_title' && $post) { $value = $post->post_title; } elseif ($result->field_name == 'tags_input' && $post) { $value = rtrim(trim(cp_get_the_term_list($post->ID, APP_TAX_TAG)), ','); } else { $value = $post_meta_val; } if ($result->field_name == 'cp_price') { //echo html( 'input', $args ); echo '<label class="form-sub-label" for="first_3" id="sublabel_first" style="color:#fff;">Maximum Budget </label><br>'; } $field_class = $result->field_req ? 'text required' : 'text'; $field_minlength = empty($result->field_min_length) ? '2' : $result->field_min_length; $args = array('value' => $value, 'name' => $result->field_name, 'id' => $result->field_name, 'type' => 'text', 'class' => $field_class, 'minlength' => $field_minlength, 'placeholder' => $result->field_label); $args = apply_filters('cp_formbuilder_' . $result->field_name, $args, $result, $post); echo html('input', $args); echo html('div', array('class' => 'clr')); break; case 'drop-down': case 'multiple-drop-down': $options = explode(',', $result->field_values); $options = array_map('trim', $options); $html_options = ''; if ($result->field_type == 'multiple-drop-down') { echo '<label class="form-sub-label mobileonly" for="first_3" id="sublabel_first" style="color:#fff;">' . $result->field_label . '</label><br>'; } $html_options .= html('option', array('value' => ''), __($result->field_label, APP_TD)); foreach ($options as $option) { $args = array('value' => $option); if ($option == $post_meta_val) { $args['selected'] = 'selected'; } $args = apply_filters('cp_formbuilder_' . $result->field_name . '_option', $args, $result, $post); $html_options .= html('option', $args, $option); } $field_class = $result->field_req ? 'dropdownlist required' : 'dropdownlist'; if ($result->field_type == 'multiple-drop-down') { $args = array('name' => $result->field_name . '[]', 'id' => $result->field_name . '[]', 'class' => $field_class, 'multiple' => "multiple"); } elseif ($result->field_type == 'drop-down' && $result->field_name == 'cp_age') { echo '<label class="form-sub-label mobileonly" for="first_3" id="sublabel_first" style="color:#fff;">' . $result->field_label . '</label><br>'; $args = array('name' => $result->field_name . '[]', 'id' => $result->field_name . '[]', 'class' => $field_class, 'multiple' => "multiple"); } elseif ($result->field_type == 'drop-down' && $result->field_name == 'cp_color') { echo '<label class="form-sub-label mobileonly" for="first_3" id="sublabel_first" style="color:#fff;">' . $result->field_label . '</label><br>'; $args = array('name' => $result->field_name . '[]', 'id' => $result->field_name . '[]', 'class' => $field_class, 'multiple' => "multiple"); } elseif ($result->field_type == 'drop-down' && $result->field_name == 'cp_state') { echo '<label class="form-sub-label mobileonly" for="first_3" id="sublabel_first" style="color:#fff;">' . $result->field_label . '</label><br>'; $args = array('name' => $result->field_name . '[]', 'id' => $result->field_name . '[]', 'class' => $field_class, 'multiple' => "multiple"); } else { $args = array('name' => $result->field_name, 'id' => $result->field_name, 'class' => $field_class); } $args = apply_filters('cp_formbuilder_' . $result->field_name, $args, $result, $post); echo html('select', $args, $html_options); echo html('div', array('class' => 'clr')); break; case 'text area': if (isset($_POST[$result->field_name])) { $value = wp_kses_post(appthemes_clean($_POST[$result->field_name])); } elseif ($result->field_name == 'post_content' && $post) { $value = $post->post_content; } else { $value = $post_meta_val; } $field_class = $result->field_req ? 'required' : ''; $field_minlength = empty($result->field_min_length) ? '2' : $result->field_min_length; $args = array('value' => $value, 'name' => $result->field_name, 'id' => $result->field_name, 'rows' => '8', 'cols' => '40', 'class' => $field_class, 'minlength' => $field_minlength, 'placeholder' => $result->field_label); $args = apply_filters('cp_formbuilder_' . $result->field_name, $args, $result, $post); $value = $args['value']; unset($args['value']); echo html('div', array('class' => 'clr')); echo html('textarea', $args, esc_textarea($value)); echo html('div', array('class' => 'clr')); ?> <?php if ($cp_options->allow_html && !wp_is_mobile()) { ?> <script type="text/javascript"> <!-- tinyMCE.execCommand('mceAddControl', false, '<?php echo esc_attr($result->field_name); ?> '); --></script> <?php } ?> <?php break; case 'radio': $options = explode(',', $result->field_values); $options = array_map('trim', $options); $html_radio = ''; $html_options = ''; if (!$result->field_req) { $args = array('value' => '', 'type' => 'radio', 'class' => 'radiolist', 'name' => $result->field_name, 'id' => $result->field_name); if (empty($post_meta_val)) { $args['checked'] = 'checked'; } $args = apply_filters('cp_formbuilder_' . $result->field_name, $args, $result, $post); $html_radio = html('input', $args) . ' ' . __('None', APP_TD); $html_options .= html('li', array(), $html_radio); } foreach ($options as $option) { $field_class = $result->field_req ? 'radiolist required' : 'radiolist'; $args = array('value' => $option, 'type' => 'radio', 'class' => $field_class, 'name' => $result->field_name, 'id' => $result->field_name); if ($option == $post_meta_val) { $args['checked'] = 'checked'; } $args = apply_filters('cp_formbuilder_' . $result->field_name, $args, $result, $post); $html_radio = html('input', $args) . ' ' . $option; $html_options .= html('li', array(), $html_radio); } echo html('ol', array('class' => 'radios'), $html_options); echo html('div', array('class' => 'clr')); break; case 'checkbox': $post_meta_val = $post ? get_post_meta($post->ID, $result->field_name, false) : array(); $options = explode(',', $result->field_values); $options = array_map('trim', $options); $optionCursor = 1; $html_checkbox = ''; $html_options = ''; foreach ($options as $option) { $field_class = $result->field_req ? 'checkboxlist required' : 'checkboxlist'; $args = array('value' => $option, 'type' => 'checkbox', 'class' => $field_class, 'name' => $result->field_name . '[]', 'id' => $result->field_name . '_' . $optionCursor++); if (in_array($option, $post_meta_val)) { $args['checked'] = 'checked'; } $args = apply_filters('cp_formbuilder_' . $result->field_name, $args, $result, $post); $html_checkbox = html('input', $args) . ' ' . $option; $html_options .= html('li', array(), $html_checkbox); } echo html('ol', array('class' => 'checkboxes'), $html_options); echo html('div', array('class' => 'clr')); break; } ?> </li> <?php } // put all the custom field names into an hidden field so we can process them on save //$custom_fields_vals['cp_type' //var_dump($custom_fields_array); $custom_fields_array[] = 'cp_type'; //var_dump($custom_fields_array); //exit; $custom_fields_vals = implode(',', $custom_fields_array); echo html('input', array('type' => 'hidden', 'name' => 'custom_fields_vals', 'value' => $custom_fields_vals)); cp_action_formbuilder($results, $post); }
/** * Retrieves Listing object. * * @param int $listing_id The listing ID. * @param int $checkout_listing Optional. Is this a valid checkout listing or an auto draft. * * @return object */ function cp_get_listing_obj($listing_id = 0, $checkout_listing = true) { $listing_id = $listing_id ? $listing_id : get_the_ID(); $listing = get_post($listing_id); if (!$listing) { return false; } if ($checkout_listing) { $categories = wp_get_post_terms($listing->ID, APP_TAX_CAT); } $listing->category = !empty($categories) ? $categories[0]->term_id : false; $form_id = cp_get_form_id($listing->category); $form_fields = cp_get_custom_form_fields($form_id); foreach ($form_fields as $field) { if (in_array($field->field_name, array('post_title', 'post_content'))) { continue; } else { if ($field->field_name == 'tags_input') { $listing->{$field->field_name} = rtrim(trim(cp_get_the_term_list($listing->ID, APP_TAX_TAG)), ','); } else { $is_single = $field->field_type != 'checkbox'; $listing->{$field->field_name} = get_post_meta($listing->ID, $field->field_name, $is_single); } } } // Clear the default 'Auto Draft' title if ($listing->post_title == __('Auto Draft')) { $listing->post_title = ''; } return $listing; }
function cp_edit_ad_formbuilder($results, $getad) { global $wpdb; // create array before adding custom fields $custom_fields_array = array(); foreach ($results as $result) { // get all the custom fields on the post and put into an array $custom_field_keys = get_post_custom_keys($getad->ID); if (!$custom_field_keys) { continue; } // wp_die('Error: There are no custom fields'); // we only want key values that match the field_name in the custom field table or core WP fields. if (in_array($result->field_name, $custom_field_keys) || $result->field_name == 'post_content' || $result->field_name == 'post_title' || $result->field_name == 'tags_input' || $result->field_type == 'checkbox') { // add each custom field name to an array so we can save them correctly later if (appthemes_str_starts_with($result->field_name, 'cp_')) { $custom_fields_array[] = $result->field_name; } // we found a match so go fetch the custom field value $post_meta_val = get_post_meta($getad->ID, $result->field_name, true); // now loop through the form builder and make the proper field and display the value switch ($result->field_type) { case 'text box': ?> <li id="list_<?php echo $result->field_name; ?> "> <div class="labelwrapper"> <label><?php if ($result->field_tooltip) { ?> <a href="#" tip="<?php esc_attr_e($result->field_tooltip); ?> " tabindex="999"><div class="helpico"></div></a><?php } esc_html_e($result->field_label); ?> : <?php if ($result->field_req) { echo '<span class="colour">*</span>'; } ?> </label><br /> <label class="invalid" for="<?php echo $result->field_name; if (stristr($result->field_name, 'checkbox')) { echo '_list'; } ?> "><?php _e('This field is required.', 'appthemes'); ?> </label> </div> <input name="<?php esc_attr_e($result->field_name); ?> " id="<?php esc_attr_e($result->field_name); ?> " type="text" class="text<?php if ($result->field_req) { echo ' required'; } ?> " style="min-width:200px;" value="<?php if ($result->field_name == 'post_title') { esc_attr_e($getad->post_title); } elseif ($result->field_name == 'tags_input') { echo rtrim(trim(cp_get_the_term_list($getad->ID, APP_TAX_TAG)), ','); } else { esc_attr_e($post_meta_val); } ?> " /> <div class="clr"></div> </li> <?php break; case 'drop-down': ?> <li id="list_<?php echo $result->field_name; ?> "> <div class="labelwrapper"> <label><?php if ($result->field_tooltip) { ?> <a href="#" tip="<?php esc_attr_e($result->field_tooltip); ?> " tabindex="999"><div class="helpico"></div></a><?php } esc_html_e($result->field_label); ?> : <?php if ($result->field_req) { echo '<span class="colour">*</span>'; } ?> </label><br /> <label class="invalid" for="<?php esc_attr_e($result->field_name); if (stristr($result->field_name, 'checkbox')) { echo '_list'; } ?> "><?php _e('This field is required.', 'appthemes'); ?> </label> </div> <select name="<?php esc_attr_e($result->field_name); ?> " class="dropdownlist<?php if ($result->field_req) { echo ' required'; } ?> "> <?php if (!$result->field_req) { ?> <option value="">-- <?php _e('Select', 'appthemes'); ?> --</option><?php } ?> <?php $options = explode(',', $result->field_values); foreach ($options as $option) { ?> <option style="min-width:177px" <?php if ($post_meta_val == trim($option)) { echo 'selected="yes"'; } ?> value="<?php echo trim(esc_attr($option)); ?> "><?php echo trim(esc_attr($option)); ?> </option> <?php } ?> </select> <div class="clr"></div> </li> <?php break; case 'text area': ?> <li id="list_<?php echo $result->field_name; ?> "> <div class="labelwrapper"> <label><?php if ($result->field_tooltip) { ?> <a href="#" tip="<?php esc_attr_e($result->field_tooltip); ?> " tabindex="999"><div class="helpico"></div></a><?php } esc_html_e($result->field_label); ?> : <?php if ($result->field_req) { echo '<span class="colour">*</span>'; } ?> </label><br /> <label class="invalid" for="<?php esc_attr_e($result->field_name); if (stristr($result->field_name, 'checkbox')) { echo '_list'; } ?> "><?php _e('This field is required.', 'appthemes'); ?> </label> </div> <div class="clr"></div> <textarea rows="4" cols="23" class="<?php if ($result->field_req) { echo ' required'; } ?> " name="<?php esc_attr_e($result->field_name); ?> " id="<?php esc_attr_e($result->field_name); ?> "><?php if ($result->field_name == 'post_content') { esc_html_e($getad->post_content); } else { echo esc_html_e($post_meta_val); } ?> </textarea> <div class="clr"></div> <?php if (get_option('cp_allow_html') == 'yes') { ?> <script type="text/javascript"> <!-- tinyMCE.execCommand('mceAddControl', false, '<?php esc_attr_e($result->field_name); ?> '); --></script> <?php } ?> </li> <?php break; case 'radio': $options = explode(',', $result->field_values); ?> <li id="list_<?php esc_attr_e($result->field_name); ?> "> <div class="labelwrapper"> <label><?php if ($result->field_tooltip) { ?> <a href="#" tip="<?php esc_attr_e($result->field_tooltip); ?> " tabindex="999"><div class="helpico"></div></a><?php } esc_html_e($result->field_label); ?> : <?php if ($result->field_req) { echo '<span class="colour">*</span>'; } ?> </label> </div> <ol class="radios"> <?php if (!$result->field_req) { ?> <li> <input type="radio" name="<?php esc_attr_e($result->field_name); ?> " id="<?php esc_attr_e($result->field_name); ?> " class="radiolist" <?php if (trim($post_meta_val) == trim($option) || !$post_meta_val) { echo 'checked="checked"'; } ?> value=""> <?php echo __('None'); ?> </li> <?php } foreach ($options as $option) { ?> <li> <input type="radio" name="<?php esc_attr_e($result->field_name); ?> " id="<?php esc_attr_e($result->field_name); ?> " value="<?php esc_html_e($option); ?> " class="radiolist <?php if ($result->field_req) { echo 'required'; } ?> " <?php if (trim($post_meta_val) == trim($option)) { echo 'checked="checked"'; } ?> > <?php esc_html_e(trim($option)); ?> </li> <!-- #radio-button --> <?php } ?> </ol> <div class="clr"></div> </li> <?php break; case 'checkbox': $options = explode(',', $result->field_values); // fetch the custom field values as array $post_meta_val = get_post_meta($getad->ID, $result->field_name, false); ?> <li id="list_<?php esc_attr_e($result->field_name); ?> "> <div class="labelwrapper"> <label><?php if ($result->field_tooltip) { ?> <a href="#" tip="<?php esc_attr_e($result->field_tooltip); ?> " tabindex="999"><div class="helpico"></div></a><?php } esc_html_e($result->field_label); ?> : <?php if ($result->field_req) { echo '<span class="colour">*</span>'; } ?> </label> </div> <ol class="checkboxes"> <?php $optionCursor = 1; foreach ($options as $option) { ?> <li> <input type="checkbox" name="<?php esc_attr_e($result->field_name); ?> []" id="<?php esc_attr_e($result->field_name); echo '_' . $optionCursor++; ?> " value="<?php esc_attr_e($option); ?> " class="checkboxlist <?php if ($result->field_req) { echo 'required'; } ?> " <?php if (is_array($post_meta_val) && in_array(trim($option), $post_meta_val)) { echo 'checked="checked"'; } ?> /> <?php echo trim(esc_html($option)); ?> </li> <!-- #checkbox --> <?php } ?> </ol> <div class="clr"></div> </li> <?php break; } } } // put all the custom field names into an hidden field so we can process them on save $custom_fields_vals = implode(',', $custom_fields_array); ?> <input type="hidden" name="custom_fields_vals" value="<?php echo $custom_fields_vals; ?> " /> <?php }
function cp_edit_ad_formbuilder($results, $getad) { //------------EKLEME-------------- (AV Cozulup cozulmemesine gore update etme) $solved = get_post_meta($getad->ID, 'cp_av_solved', true); ?> <li id="list_cp_av_solved"> <div class="labelwrapper"> <label><a href="#" tip="Lutfen Erisim Engelinin cozulup cozulmedigini seciniz!" tabindex="999"><div class="helpico"></div></a>Erisim Engeli Durumu : <span class="colour">*</span></label><br /> <label class="invalid" for="cp_av_solved">Bu alanin secilmesi zorunlu!</label> </div> <select name="cp_av_solved" id="cp_av_solved" class="dropdownlist required"> <?php if ($solved != null && $solved == 'yes') { // Eger kayit varsa cozulmus demektir ?> <option style="min-width:177px" selected="yes" value="yes">Cozuldu</option> <option style="min-width:177px" value="no">Cozulmedi</option> <?php } else { // Eger kayit yoksa cozulmemis demektir ?> <option style="min-width:177px" value="yes">Cozuldu</option> <option style="min-width:177px" selected="yes" value="no">Cozulmedi</option> <?php } ?> </select> <div class="clr"></div> </li> <?php //---------------------------------- global $wpdb; // create array before adding custom fields $custom_fields_array = array(); foreach ($results as $result) { // get all the custom fields on the post and put into an array $custom_field_keys = get_post_custom_keys($getad->ID); if (!$custom_field_keys) { continue; } // wp_die('Error: There are no custom fields'); // we only want key values that match the field_name in the custom field table or core WP fields. if (in_array($result->field_name, $custom_field_keys) || $result->field_name == 'post_content' || $result->field_name == 'post_title' || $result->field_name == 'tags_input' || $result->field_type == 'checkbox') { // add each custom field name to an array so we can save them correctly later if (appthemes_str_starts_with($result->field_name, 'cp_')) { $custom_fields_array[] = $result->field_name; } // we found a match so go fetch the custom field value $post_meta_val = get_post_meta($getad->ID, $result->field_name, true); // now loop through the form builder and make the proper field and display the value //************************************** EKLEME ************************************************************** switch ($result->field_type) { case 'text box': ?> <li id="list_<?php echo $result->field_name; ?> "> <div class="labelwrapper"> <label><?php if ($result->field_tooltip) { ?> <a href="#" tip="<?php echo esc_attr(translate($result->field_tooltip, 'appthemes')); ?> " tabindex="999"><div class="helpico"></div></a><?php } echo esc_html(translate($result->field_label, 'appthemes')); ?> : <?php if ($result->field_req) { echo '<span class="colour">*</span>'; } ?> </label><br /> <label class="invalid" for="<?php echo $result->field_name; if (stristr($result->field_name, 'checkbox')) { echo '_list'; } ?> "><?php _e('This field is required.', 'appthemes'); ?> </label> </div> <input name="<?php echo esc_attr($result->field_name); ?> " id="<?php echo esc_attr($result->field_name); ?> " type="text" class="text<?php if ($result->field_req) { echo ' required'; } ?> " style="min-width:200px;" value="<?php if ($result->field_name == 'post_title') { echo esc_attr($getad->post_title); } elseif ($result->field_name == 'tags_input') { echo rtrim(trim(cp_get_the_term_list($getad->ID, APP_TAX_TAG)), ','); } else { echo esc_attr($post_meta_val); } ?> " /> <div class="clr"></div> </li> <?php break; case 'drop-down': ?> <li id="list_<?php echo esc_attr($result->field_name); ?> "> <div class="labelwrapper"> <label><?php if ($result->field_tooltip) { ?> <a href="#" tip="<?php echo esc_attr(translate($result->field_tooltip, 'appthemes')); ?> " tabindex="999"><div class="helpico"></div></a><?php } echo esc_html(translate($result->field_label, 'appthemes')); ?> : <?php if ($result->field_req) { echo '<span class="colour">*</span>'; } ?> </label><br /> <label class="invalid" for="<?php echo esc_attr($result->field_name); if (stristr($result->field_name, 'checkbox')) { echo '_list'; } ?> "><?php _e('This field is required.', 'appthemes'); ?> </label> </div> <select name="<?php echo esc_attr($result->field_name); ?> " id="<?php echo esc_attr($result->field_name); ?> " class="dropdownlist<?php if ($result->field_req) { echo ' required'; } ?> "> <?php if (!$result->field_req) { ?> <option value="">-- <?php _e('Select', 'appthemes'); ?> --</option><?php } ?> <?php $options = explode(',', $result->field_values); foreach ($options as $option) { ?> <option style="min-width:177px" <?php if ($post_meta_val == trim($option)) { echo 'selected="yes"'; } ?> value="<?php echo trim(esc_attr($option)); ?> "><?php echo trim(esc_attr($option)); ?> </option> <?php } ?> </select> <div class="clr"></div> </li> <?php break; case 'text area': ?> <li id="list_<?php echo $result->field_name; ?> "> <div class="labelwrapper"> <label><?php if ($result->field_tooltip) { ?> <a href="#" tip="<?php echo esc_attr(translate($result->field_tooltip, 'appthemes')); ?> " tabindex="999"><div class="helpico"></div></a><?php } echo esc_html(translate($result->field_label, 'appthemes')); ?> : <?php if ($result->field_req) { echo '<span class="colour">*</span>'; } ?> </label><br /> <label class="invalid" for="<?php echo esc_attr($result->field_name); if (stristr($result->field_name, 'checkbox')) { echo '_list'; } ?> "><?php _e('This field is required.', 'appthemes'); ?> </label> </div> <div class="clr"></div> <textarea rows="4" cols="23" class="<?php if ($result->field_req) { echo ' required'; } ?> " name="<?php echo esc_attr($result->field_name); ?> " id="<?php echo esc_attr($result->field_name); ?> "><?php if ($result->field_name == 'post_content') { echo esc_textarea($getad->post_content); } else { echo esc_textarea($post_meta_val); } ?> </textarea> <div class="clr"></div> <?php if (get_option('cp_allow_html') == 'yes') { ?> <script type="text/javascript"> <!-- tinyMCE.execCommand('mceAddControl', false, '<?php echo esc_attr($result->field_name); ?> '); --></script> <?php } ?> </li> <?php break; case 'radio': $options = explode(',', $result->field_values); ?> <li id="list_<?php echo esc_attr($result->field_name); ?> "> <div class="labelwrapper"> <label><?php if ($result->field_tooltip) { ?> <a href="#" tip="<?php echo esc_attr(translate($result->field_tooltip, 'appthemes')); ?> " tabindex="999"><div class="helpico"></div></a><?php } echo esc_html(translate($result->field_label, 'appthemes')); ?> : <?php if ($result->field_req) { echo '<span class="colour">*</span>'; } ?> </label> </div> <ol class="radios"> <?php if (!$result->field_req) { ?> <li> <input type="radio" name="<?php echo esc_attr($result->field_name); ?> " id="<?php echo esc_attr($result->field_name); ?> " class="radiolist" <?php if (trim($post_meta_val) == trim($option) || !$post_meta_val) { echo 'checked="checked"'; } ?> value=""> <?php _e('None', 'appthemes'); ?> </li> <?php } foreach ($options as $option) { ?> <li> <input type="radio" name="<?php echo esc_attr($result->field_name); ?> " id="<?php echo esc_attr($result->field_name); ?> " value="<?php echo esc_html($option); ?> " class="radiolist <?php if ($result->field_req) { echo 'required'; } ?> " <?php if (trim($post_meta_val) == trim($option)) { echo 'checked="checked"'; } ?> > <?php echo esc_html(trim($option)); ?> </li> <!-- #radio-button --> <?php } ?> </ol> <div class="clr"></div> </li> <?php break; case 'checkbox': $options = explode(',', $result->field_values); // fetch the custom field values as array $post_meta_val = get_post_meta($getad->ID, $result->field_name, false); ?> <li id="list_<?php echo esc_attr($result->field_name); ?> "> <div class="labelwrapper"> <label><?php if ($result->field_tooltip) { ?> <a href="#" tip="<?php echo esc_attr(translate($result->field_tooltip, 'appthemes')); ?> " tabindex="999"><div class="helpico"></div></a><?php } echo esc_html(translate($result->field_label, 'appthemes')); ?> : <?php if ($result->field_req) { echo '<span class="colour">*</span>'; } ?> </label> </div> <ol class="checkboxes"> <?php $optionCursor = 1; foreach ($options as $option) { ?> <li> <input type="checkbox" name="<?php echo esc_attr($result->field_name); ?> []" id="<?php echo esc_attr($result->field_name); echo '_' . $optionCursor++; ?> " value="<?php echo esc_attr($option); ?> " class="checkboxlist <?php if ($result->field_req) { echo 'required'; } ?> " <?php if (is_array($post_meta_val) && in_array(trim($option), $post_meta_val)) { echo 'checked="checked"'; } ?> /> <?php echo trim(esc_html($option)); ?> </li> <!-- #checkbox --> <?php } ?> </ol> <div class="clr"></div> </li> <?php break; } // END SWITCH //}// END ELSE } } // put all the custom field names into an hidden field so we can process them on save $custom_fields_vals = implode(',', $custom_fields_array); ?> <input type="hidden" name="custom_fields_vals" value="<?php echo $custom_fields_vals; ?> " /> <script language="javascript"> cp_country = document.getElementById('cp_country'); if(cp_country){ print_country("cp_country"); set_country("cp_country",'cp_state',''); // Set Default Country here cp_country.setAttribute("onChange", "print_state('cp_state',this.selectedIndex);" ); } </script> <?php }