Example #1
0
    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"', '&nbsp;'));
            } 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) . '&nbsp;&nbsp;' . __('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) . '&nbsp;&nbsp;' . $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) . '&nbsp;&nbsp;' . $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_add_new_listing($advals)
{
    global $wpdb;
    $new_tags = '';
    $ad_length = '';
    $attach_id = '';
    $the_attachment = '';
    // tags are tricky and need to be put into an array before saving the ad
    if (!empty($advals['tags_input'])) {
        $new_tags = explode(',', $advals['tags_input']);
    }
    // put all the new ad elements into an array
    // these are the minimum required fields for WP (except tags)
    $new_ad = array();
    $new_ad['post_title'] = appthemes_filter($advals['post_title']);
    $new_ad['post_content'] = trim($advals['post_content']);
    $new_ad['post_status'] = 'pending';
    // no longer setting final status until after images are set
    $new_ad['post_author'] = 0;
    if (!empty($_SESSION['anonym']) && $_SESSION['anonym'] != '') {
        $new_ad['post_author'] = 0;
    } else {
        $new_ad['post_author'] = $advals['user_id'];
    }
    $new_ad['post_type'] = APP_POST_TYPE;
    // make sure the WP sanitize_post function doesn't strip out embed & other html
    if (get_option('cp_allow_html') == 'yes') {
        $new_ad['filter'] = true;
    }
    //print_r($new_ad).' <- new ad array<br>';
    // insert the new ad
    $post_id = wp_insert_post($new_ad);
    //set the custom post type categories
    wp_set_post_terms($post_id, appthemes_filter($advals['cat']), APP_TAX_CAT, false);
    //set the custom post type tags
    wp_set_post_terms($post_id, $new_tags, APP_TAX_TAG, false);
    //$location = get_field('location');
    //**************************************EKLEME**********************************************
    // Google Maps ten Pozisyon Seçilmiþse O pozisyonu kaydeder seçimemiþse adresten bulur
    if (!empty($_SESSION['kordinat']) && $_SESSION['kordinat'] != '') {
        $category = get_the_terms($post_id, 'ad_cat');
        $address1 = explode('|', $_SESSION['kordinat']);
        $address2 = explode(',', $address1[1]);
        cp_add_geocode($post_id, $category[0]->name, $address2[0], $address2[1]);
        $_SESSION['kordinat'] = '';
    } else {
        $_SESSION['kordinat'] == 'yok';
    }
    //************************************************************************************
    // the unique order ID we created becomes the ad confirmation ID
    // we will use this for payment systems and for activating the ad
    // later if need be. it needs to start with cp_ otherwise it won't
    // be loaded in with the ad so let's give it a new name
    $advals['cp_sys_ad_conf_id'] = $advals['oid'];
    // get the ad duration and first see if ad packs are being used
    // if so, get the length of time in days otherwise use the default
    // prune period defined on the CP settings page
    if (isset($advals['pack_duration'])) {
        $ad_length = $advals['pack_duration'];
    } else {
        $ad_length = get_option('cp_prun_period');
    }
    // set the ad listing expiration date and put into a session
    $ad_expire_date = date_i18n('m/d/Y H:i:s', strtotime('+' . $ad_length . ' days'));
    // don't localize the word 'days'
    $advals['cp_sys_expire_date'] = $ad_expire_date;
    $advals['cp_sys_ad_duration'] = $ad_length;
    // now add all the custom fields into WP post meta fields
    foreach ($advals as $meta_key => $meta_value) {
        if (appthemes_str_starts_with($meta_key, 'cp_') && !is_array($advals[$meta_key])) {
            add_post_meta($post_id, $meta_key, $meta_value, true);
        }
        if (appthemes_str_starts_with($meta_key, 'cp_') && is_array($advals[$meta_key])) {
            foreach ($advals[$meta_key] as $checkbox_value) {
                add_post_meta($post_id, $meta_key, $checkbox_value);
            }
        }
    }
    // if they checked the box for a featured ad, then make the post sticky
    if (isset($advals['featured_ad'])) {
        stick_post($post_id);
    }
    if (isset($advals['attachment'])) {
        $the_attachment = $advals['attachment'];
        // associate the already uploaded images to the new ad and create multiple image sizes
        $attach_id = cp_associate_images($post_id, $the_attachment, true);
    }
    // set the thumbnail pic on the WP post
    //cp_set_ad_thumbnail($post_id, $attach_id);
    //last step is to publish the ad when its appropriate to publish immediately
    $final_status = cp_set_post_status($advals);
    if ($final_status == 'publish') {
        $final_post = array();
        $final_post['ID'] = $post_id;
        $final_post['post_status'] = $final_status;
        $update_result = wp_update_post($final_post);
    }
    // kick back the post id in case we want to use it
    return $post_id;
}
function cp_add_new_listing($advals, $renew_id = false)
{
    global $wpdb, $cp_options;
    $new_tags = '';
    $ad_length = '';
    $attach_id = '';
    $the_attachment = '';
    // check to see if html is allowed
    if (!$cp_options->allow_html) {
        $post_content = appthemes_filter($advals['post_content']);
    } else {
        $post_content = wp_kses_post($advals['post_content']);
    }
    // tags are tricky and need to be put into an array before saving the ad
    if (!empty($advals['tags_input'])) {
        $new_tags = explode(',', $advals['tags_input']);
    }
    // put all the new ad elements into an array
    // these are the minimum required fields for WP (except tags)
    $new_ad = array();
    $new_ad['post_title'] = appthemes_filter($advals['post_title']);
    $new_ad['post_content'] = trim($post_content);
    $new_ad['post_status'] = 'pending';
    // no longer setting final status until after images are set
    $new_ad['post_author'] = $advals['user_id'];
    $new_ad['post_type'] = APP_POST_TYPE;
    if ($renew_id) {
        $new_ad['ID'] = $renew_id;
        $new_ad['post_date'] = current_time('mysql');
        $new_ad['post_date_gmt'] = current_time('mysql', 1);
        $post_id = wp_update_post($new_ad);
    } else {
        // insert the new ad
        $post_id = wp_insert_post($new_ad);
    }
    //set the custom post type categories
    wp_set_post_terms($post_id, appthemes_filter($advals['cat']), APP_TAX_CAT, false);
    //set the custom post type tags
    wp_set_post_terms($post_id, $new_tags, APP_TAX_TAG, false);
    // the unique order ID we created becomes the ad confirmation ID
    // we will use this for payment systems and for activating the ad
    // later if need be. it needs to start with cp_ otherwise it won't
    // be loaded in with the ad so let's give it a new name
    $advals['cp_sys_ad_conf_id'] = $advals['oid'];
    // get the ad duration and first see if ad packs are being used
    // if so, get the length of time in days otherwise use the default
    // prune period defined on the CP settings page
    if (isset($advals['pack_duration'])) {
        $ad_length = $advals['pack_duration'];
    } else {
        $ad_length = $cp_options->prun_period;
    }
    // set the ad listing expiration date and put into a session
    $ad_expire_date = appthemes_mysql_date(current_time('mysql'), $ad_length);
    $advals['cp_sys_expire_date'] = $ad_expire_date;
    $advals['cp_sys_ad_duration'] = $ad_length;
    // if renew ad - delete all old post meta and unmark ad as featured
    if ($renew_id) {
        unstick_post($renew_id);
        $custom_field_keys = get_post_custom_keys($renew_id);
        foreach ($custom_field_keys as $custom_key) {
            delete_post_meta($renew_id, $custom_key);
        }
    }
    // now add all the custom fields into WP post meta fields
    foreach ($advals as $meta_key => $meta_value) {
        if (appthemes_str_starts_with($meta_key, 'cp_') && !is_array($advals[$meta_key])) {
            add_post_meta($post_id, $meta_key, wp_kses_post($meta_value), true);
        }
        if (appthemes_str_starts_with($meta_key, 'cp_') && is_array($advals[$meta_key])) {
            foreach ($advals[$meta_key] as $checkbox_value) {
                add_post_meta($post_id, $meta_key, wp_kses_post($checkbox_value));
            }
        }
    }
    // if they checked the box for a featured ad, then make the post sticky
    if (isset($advals['featured_ad'])) {
        stick_post($post_id);
    }
    if (isset($advals['attachment'])) {
        $the_attachment = $advals['attachment'];
        // associate the already uploaded images to the new ad and create multiple image sizes
        $attach_id = cp_associate_images($post_id, $the_attachment, true);
    }
    if (isset($advals['app_attach_id'])) {
        $attachments = $advals['app_attach_id'];
        $titles = isset($advals['app_attach_title']) ? $advals['app_attach_title'] : array();
        // associate the already uploaded images to the new ad and update titles
        $attach_id = appthemes_plupload_associate_images($post_id, $attachments, $titles, true);
    }
    // set the thumbnail pic on the WP post
    //cp_set_ad_thumbnail($post_id, $attach_id);
    //last step is to publish the ad when its appropriate to publish immediately
    $final_status = cp_set_post_status($advals);
    if ($final_status == 'publish') {
        $final_post = array();
        $final_post['ID'] = $post_id;
        $final_post['post_status'] = $final_status;
        $update_result = wp_update_post($final_post);
    }
    cp_action_add_new_listing($post_id);
    // kick back the post id in case we want to use it
    return $post_id;
}
Example #4
0
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"';
                        }
                        ?>
>&nbsp;&nbsp;<?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"';
                        }
                        ?>
 />&nbsp;&nbsp;&nbsp;<?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 
}
Example #5
0
/**
 * Convert old settings to scbOptions format.
 *
 * @since 3.3
 */
function cp_upgrade_settings_330()
{
    global $wpdb, $cp_options;
    $new_options = array();
    $options_to_delete = array();
    // fields to convert from select 'yes/no' to checkbox
    $select_fields = array('allow_registration_password', 'use_logo', 'search_ex_pages', 'search_ex_blog', 'search_custom_fields', 'ad_edit', 'allow_relist', 'ad_inquiry_form', 'allow_html', 'ad_stats_all', 'ad_gravatar_thumb', 'post_prune', 'ad_images', 'ad_image_preview', 'captcha_enable', 'adcode_468x60_enable', 'adcode_336x280_enable', 'disable_stylesheet', 'debug_mode', 'google_jquery', 'disable_wp_login', 'remove_wp_generator', 'remove_admin_bar', 'display_website_time', 'cufon_enable', 'new_ad_email', 'prune_ads_email', 'new_ad_email_owner', 'expired_ad_email_owner', 'nu_admin_email', 'membership_activated_email_owner', 'membership_ending_reminder_email', 'nu_custom_email', 'charge_ads', 'enable_featured', 'clean_price_field', 'force_zeroprice', 'hide_decimals', 'enable_membership_packs');
    // fields to translate
    $fields_to_translate = array('cp_curr_pay_type' => 'currency_code', 'cp_curr_symbol_pos' => 'currency_position');
    // legacy settings
    $legacy_options = $wpdb->get_results("SELECT * FROM {$wpdb->options} WHERE option_name LIKE 'cp_%'");
    if (!$legacy_options) {
        return;
    }
    foreach ($legacy_options as $option) {
        $new_option_name = substr($option->option_name, 3);
        // grab price per category options into an array
        $is_cat_price = appthemes_str_starts_with($new_option_name, 'cat_price_');
        if ($is_cat_price) {
            $cat_id = substr($new_option_name, 10);
            $new_options['price_per_cat'][$cat_id] = $option->option_value;
            $options_to_delete[] = $option->option_name;
            continue;
        }
        // translate old payment settings to new one
        if (array_key_exists($option->option_name, $fields_to_translate)) {
            $new_options[$fields_to_translate[$option->option_name]] = $option->option_value;
            $options_to_delete[] = $option->option_name;
            continue;
        }
        // skip not used options and membership entries
        if (is_null($cp_options->{$new_option_name}) || $new_option_name == 'options') {
            continue;
        }
        // convert select 'yes/no' to checkbox
        if (in_array($new_option_name, $select_fields)) {
            $option->option_value = $option->option_value == 'yes' ? 1 : 0;
        }
        $new_options[$new_option_name] = maybe_unserialize($option->option_value);
        $options_to_delete[] = $option->option_name;
    }
    // migrate payment gateways settings
    $gateways = array('enabled' => array('paypal' => get_option('cp_enable_paypal') == 'yes' ? 1 : 0, 'bank-transfer' => get_option('cp_enable_bank') == 'yes' ? 1 : 0), 'paypal' => array('email_address' => get_option('cp_paypal_email'), 'ipn_enabled' => get_option('cp_enable_paypal_ipn') == 'yes' ? 1 : 0, 'sandbox_enabled' => get_option('cp_paypal_sandbox') ? 1 : 0), 'bank-transfer' => array('message' => get_option('cp_bank_instructions')));
    $new_options['gateways'] = $gateways;
    $options_to_delete = array_merge($options_to_delete, array('cp_enable_paypal', 'cp_enable_bank', 'cp_paypal_email', 'cp_enable_paypal_ipn', 'cp_paypal_sandbox', 'cp_bank_instructions'));
    // enable selectbox js for those, which updating
    $new_options['selectbox'] = 1;
    // save new options
    $new_options = array_merge(get_option('cp_options', array()), $new_options);
    update_option('cp_options', $new_options);
    // delete old options
    foreach ($options_to_delete as $option_name) {
        delete_option($option_name);
    }
}
Example #6
0
 /**
  * Updating listing.
  *
  * @param object $order
  * @param object $checkout
  *
  * return void
  */
 public function update_listing($order, $checkout)
 {
     global $cp_options;
     $listing = $this->get_listing_obj();
     // save internal data
     foreach ($this->posted_fields as $field_key => $field_value) {
         if (appthemes_str_starts_with($field_key, 'cp_sys_')) {
             update_post_meta($listing->ID, $field_key, wp_kses_post($field_value));
         }
     }
     // update listing status
     $listing_args = array('ID' => $listing->ID, 'post_status' => cp_set_post_status($this->posted_fields), 'post_author' => get_current_user_id(), 'post_date' => current_time('mysql'), 'post_date_gmt' => current_time('mysql', 1));
     $listing_id = wp_update_post($listing_args);
     do_action('cp_update_listing', $listing->ID, $order, $checkout);
 }
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"';
                        }
                        ?>
>&nbsp;&nbsp;<?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"';
                        }
                        ?>
 />&nbsp;&nbsp;&nbsp;<?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 
}