コード例 #1
0
ファイル: write-panel.php プロジェクト: joaosigno/dazake-job
function cp_custom_fields_meta_box()
{
    global $wpdb, $post, $meta_boxes, $key;
    // use nonce for verification
    wp_nonce_field(basename(__FILE__), $key . '_wpnonce', false, true);
    // get the ad category id
    $ad_cat_id = appthemes_get_custom_taxonomy($post->ID, APP_TAX_CAT, 'term_id');
    // get the form id
    $fid = cp_get_form_id($ad_cat_id);
    // if there's no form id it must mean the default form is being used so let's go grab those fields
    if (!$fid) {
        // use this if there's no custom form being used and give us the default form
        $sql = $wpdb->prepare("SELECT field_label, field_name, field_type, field_values, field_tooltip, field_req " . "FROM " . $wpdb->prefix . "cp_ad_fields " . "WHERE field_core = '1' " . "ORDER BY field_id asc");
    } else {
        // now we should have the formid so show the form layout based on the category selected
        $sql = $wpdb->prepare("SELECT f.field_label, f.field_name, f.field_type, f.field_values, f.field_perm, f.field_tooltip, m.meta_id, m.field_pos, m.field_req, m.form_id " . "FROM " . $wpdb->prefix . "cp_ad_fields f " . "INNER JOIN " . $wpdb->prefix . "cp_ad_meta m " . "ON f.field_id = m.field_id " . "WHERE m.form_id = %s " . "ORDER BY m.field_pos asc", $fid);
    }
    $results = $wpdb->get_results($sql);
    // display the write panel for the custom fields
    if ($results) {
        ?>
	

	<script type="text/javascript">
		//<![CDATA[	
		/* initialize the datepicker feature */
		jQuery(document).ready(function($) {		   
			$('table input#datepicker').datetimepicker({
				showSecond: true,
				timeFormat: 'hh:mm:ss',
				showOn: 'button',
				dateFormat: 'mm/dd/yy',				
				minDate: 0,
				buttonImageOnly: true,
				buttonText: '',
				buttonImage: '../wp-includes/images/blank.gif' // calling the real calendar image in the admin-style.css. need a blank placeholder image b/c of IE.
			});
		});	
		//]]>
	</script>	

		<table class="form-table ad-meta-table">
		
			<tr>
				<th style="width:20%"><label for="cp_sys_ad_conf_id"><?php 
        _e('Ad Info', 'appthemes');
        ?>
:</label></th>
				<td class="ad-conf-id">
					<div id="ad-id"><div id="keyico"></div><?php 
        _e('Ad ID', 'appthemes');
        ?>
: <span><?php 
        echo esc_html(get_post_meta($post->ID, 'cp_sys_ad_conf_id', true));
        ?>
</span></div>
					<div id="ad-stats"><div id="statsico"></div><?php 
        _e('Views Today', 'appthemes');
        ?>
: <strong><?php 
        echo esc_html(get_post_meta($post->ID, 'cp_daily_count', true));
        ?>
</strong> | <?php 
        _e('Views Total:', 'appthemes');
        ?>
 <strong><?php 
        echo esc_html(get_post_meta($post->ID, 'cp_total_count', true));
        ?>
</strong></div>
				</td>
			</tr>

			<tr>
				<th style="width:20%"><label for="cp_sys_ad_conf_id"><?php 
        _e('Submitted By', 'appthemes');
        ?>
:</label></th>
				<td style="line-height:3.4em;">
					<?php 
        // show the gravatar for the author
        echo get_avatar($post->post_author, $size = '48', $default = '');
        // show the author drop-down box
        wp_dropdown_users(array('who' => 'authors', 'name' => 'post_author_override', 'selected' => empty($post->ID) ? $user_ID : $post->post_author, 'include_selected' => true));
        // display the author display name
        $author = get_userdata($post->post_author);
        echo '<br/><a href="user-edit.php?user_id=' . $author->ID . '">' . $author->display_name . '</a>';
        ?>
				</td>
			</tr>

			<tr>
				<th style="width:20%"><label for="cp_sys_ad_conf_id"><?php 
        _e('Ad Terms', 'appthemes');
        ?>
:</label></th>
				<td><?php 
        echo cp_get_price($post->ID, 'cp_sys_total_ad_cost');
        ?>
 <?php 
        _e('for', 'appthemes');
        ?>
 <?php 
        echo esc_html(get_post_meta($post->ID, 'cp_sys_ad_duration', true));
        ?>
 <?php 
        _e('days', 'appthemes');
        ?>
</td>
			</tr>

			<tr>
				<th style="width:20%"><label for="cp_sys_expire_date"><?php 
        _e('Ad Expires', 'appthemes');
        ?>
:</label></th>
				<td><input readonly type="text" name="cp_sys_expire_date" class="text" id="datepicker" value="<?php 
        echo esc_html(get_post_meta($post->ID, 'cp_sys_expire_date', true));
        ?>
" /></td>
			</tr>			
				
			<tr>	
				<th colspan="2" style="padding:0px;">&nbsp;</th>
			</tr>		
			
			<?php 
        cp_edit_ad_fields($results, $post->ID);
        // build the edit ad meta box
        ?>
			
		
			<tr>
				<th style="width:20%"><label for="cp_sys_userIP"><?php 
        _e('Submitted from IP', 'appthemes');
        ?>
:</label></th>
				<td><?php 
        echo esc_html(get_post_meta($post->ID, 'cp_sys_userIP', true));
        ?>
</td>
			</tr>	
			
		</table>	
		
	<?php 
    }
    ?>

<?php 
}
 function cp_get_ad_details_custom($post_id, $category_id, $location = 'list')
 {
     global $wpdb;
     // see if there's a custom form first based on category id.
     $form_id = cp_get_form_id($category_id);
     $post = get_post($post_id);
     if (!$post) {
         return;
     }
     // if there's no form id it must mean the default form is being used
     if (!$form_id) {
         // get all the custom field labels so we can match the field_name up against the post_meta keys
         $sql = "SELECT field_label, field_name, field_type FROM {$wpdb->cp_ad_fields}";
     } else {
         // now we should have the formid so show the form layout based on the category selected
         $sql = $wpdb->prepare("SELECT f.field_label, f.field_name, f.field_type, m.field_pos FROM {$wpdb->cp_ad_fields} f " . "INNER JOIN {$wpdb->cp_ad_meta} m ON f.field_id = m.field_id WHERE m.form_id = %s ORDER BY m.field_pos ASC", $form_id);
     }
     $results = $wpdb->get_results($sql);
     //var_dump($results);
     if (!$results) {
         _e('No ad details found.', APP_TD);
         return;
     }
     // allows to hook before ad details
     cp_action_before_ad_details($results, $post, $location);
     /*$i=0;
     		foreach ( $results as $result ) {
     			$result[$i]=$result;
     					 $result['video_url']= 'field_label' => 'Video Url',
     				 'field_name' => 'cp_video_url' ,
     				  'field_type' => 'text box';
     				  $i++;
     		}*/
     //var_dump($result);
     foreach ($results as $result) {
         // external plugins can modify or disable field
         $result = apply_filters('cp_ad_details_field', $result, $post, $location);
         //var_dump($result);
         if (!$result) {
             continue;
         }
         //$disallow_fields = array( 'cp_price', 'cp_currency' );
         $disallow_fields = array('cp_price', 'cp_currency', 'cp_sex', 'cp_height', 'cp_color', 'cp_all_levels', 'cp_jumping_ability', 'cp_type', 'cp_city', 'cp_state', 'cp_country', 'cp_zipcode', 'cp_street', 'cp_price_display_model');
         if (in_array($result->field_name, $disallow_fields)) {
             continue;
         }
         $post_meta_val = get_post_meta($post->ID, $result->field_name, true);
         if (empty($post_meta_val)) {
             continue;
         }
         if ($location == 'list') {
             if ($result->field_type == 'text area') {
                 continue;
             }
             if ($result->field_type == 'checkbox' || $result->field_type == 'multiple-drop-down') {
                 $post_meta_val = get_post_meta($post->ID, $result->field_name, false);
                 $post_meta_val = implode(", ", $post_meta_val);
             }
             /*if($result->field_name=='cp_video_url')
             		{
             			//echo "jdghd";
             			//var_dump($post_meta_val);
             			echo '<embed width="300" height="200" src="http://www.youtube.com/v/XGSy3_Czz8k" >';
             			//echo '<embed width="420" height="315" src="http://www.youtube.com/v/XGSy3_Czz8k">';
             			echo '<embed width="300" height="200" src="http://www.youtube.com/v/XGSy3_Czz8k" >';
             	 		continue;
             		}*/
             $args = array('value' => $post_meta_val, 'label' => $result->field_label, 'id' => $result->field_name, 'class' => '');
             $args = apply_filters('cp_ad_details_' . $result->field_name, $args, $result, $post, $location);
             if ($result->field_name == 'cp_video_url') {
                 if ($args['value'] != '') {
                     $url = $args['value'];
                     if (preg_match('/[\\?\\&]v=([^\\?\\&]+)/', $url, $matches)) {
                         preg_match('/[\\?\\&]v=([^\\?\\&]+)/', $url, $matches);
                         $id = $matches[1];
                     } else {
                         $matchexplode = explode('https://youtu.be/', $url);
                         $id = $matchexplode[1];
                     }
                     $url = "http://www.youtube.com/embed/" . $id . "";
                     echo '<embed width="100%" height="auto" src="' . $url . '" >';
                     //echo '<embed width="100%" height="auto" src="'.$args['value'].'" >';
                     continue;
                 }
             }
             if ($args) {
                 $field_title_to_display = $args['label'];
             }
             $mobileclass = 'mobileoff';
             $field_title_to_display = str_replace('Any ', '', $field_title_to_display);
             $field_title_to_display = str_replace('Any', '', $field_title_to_display);
             $field_title_to_display = str_replace('For', '', $field_title_to_display);
             //var_dump($field_title_to_display);
             $value_to_display = $args['value'];
             $value_to_display_to_check = strtolower($value_to_display);
             if ($value_to_display_to_check == 'for sale or lease' || $value_to_display_to_check == 'any state' || $value_to_display_to_check == 'any color' || $value_to_display_to_check == 'any horse or pony' || $value_to_display_to_check == 'any age' || $value_to_display_to_check == 'any horse shows') {
                 $value_to_display = 'Not Specified';
             }
             if ($field_title_to_display == 'Age') {
                 $mobileclass = '';
             }
             echo '<li id="' . $args['id'] . '" class="' . $args['class'] . '"><span class="' . $mobileclass . '">' . esc_html(translate($field_title_to_display, APP_TD)) . ':</span> ' . appthemes_make_clickable($value_to_display) . '</li>';
             //echo '<li id="' . $args['id'] . '" class="' . $args['class'] . '"><span>' . esc_html( translate( $args['label'], APP_TD ) ) . ':</span> ' . appthemes_make_clickable( $args['value'] ) . '</li>';
         } elseif ($location == 'content') {
             if ($result->field_type != 'text area') {
                 continue;
             }
             $args = array('value' => $post_meta_val, 'label' => $result->field_label, 'id' => $result->field_name, 'class' => 'custom-text-area dotted');
             $args = apply_filters('cp_ad_details_' . $result->field_name, $args, $result, $post, $location);
             if ($args) {
                 echo '<div id="' . $args['id'] . '" class="' . $args['class'] . '"><h3>' . esc_html(translate($args['label'], APP_TD)) . '</h3> ' . appthemes_make_clickable($args['value']) . '</div>';
             }
         }
     }
     // allows to hook after ad details
     cp_action_after_ad_details($results, $post, $location);
 }
コード例 #3
0
ファイル: search.php プロジェクト: kalushta/darom
 function cp_show_refine_search($cat_id)
 {
     global $wpdb;
     $form_id = cp_get_form_id($cat_id);
     if (!$form_id) {
         return;
     }
     // now we should have the formid so show the form layout based on the category selected
     $sql = $wpdb->prepare("SELECT f.field_label, f.field_name, f.field_type, f.field_values, f.field_perm, m.field_search, m.meta_id, m.field_pos, m.field_req, m.form_id " . "FROM {$wpdb->cp_ad_fields} f " . "INNER JOIN {$wpdb->cp_ad_meta} m ON f.field_id = m.field_id " . "WHERE m.form_id = %s AND m.field_search = '1' " . "ORDER BY m.field_pos ASC", $form_id);
     $results = $wpdb->get_results($sql);
     if ($results) {
         echo cp_refine_search_builder($results);
         // loop through the custom form fields and display them
     }
 }
コード例 #4
0
ファイル: theme-functions.php プロジェクト: kalushta/darom
 function cp_get_ad_details($postid, $catid, $locationOption = 'list')
 {
     global $wpdb;
     //$all_custom_fields = get_post_custom($post->ID);
     // see if there's a custom form first based on catid.
     $fid = cp_get_form_id($catid);
     // if there's no form id it must mean the default form is being used
     if (!$fid) {
         // get all the custom field labels so we can match the field_name up against the post_meta keys
         $sql = "SELECT field_label, field_name, field_type FROM {$wpdb->cp_ad_fields}";
     } else {
         // now we should have the formid so show the form layout based on the category selected
         $sql = $wpdb->prepare("SELECT f.field_label, f.field_name, f.field_type, m.field_pos " . "FROM {$wpdb->cp_ad_fields} f " . "INNER JOIN {$wpdb->cp_ad_meta} m " . "ON f.field_id = m.field_id " . "WHERE m.form_id = %s " . "ORDER BY m.field_pos asc", $fid);
     }
     $results = $wpdb->get_results($sql);
     if ($results) {
         if ($locationOption == 'list') {
             foreach ($results as $result) {
                 // now grab all ad fields and print out the field label and value
                 $post_meta_val = get_post_meta($postid, $result->field_name, true);
                 if (!empty($post_meta_val)) {
                     if ($result->field_type == "checkbox") {
                         $post_meta_val = get_post_meta($postid, $result->field_name, false);
                         echo '<li id="' . $result->field_name . '"><span>' . esc_html(translate($result->field_label, APP_TD)) . ':</span> ' . appthemes_make_clickable(implode(", ", $post_meta_val)) . '</li>';
                         // make_clickable is a WP function that auto hyperlinks urls}
                     } elseif ($result->field_name != 'cp_price' && $result->field_name != 'cp_currency' && $result->field_type != "text area") {
                         echo '<li id="' . $result->field_name . '"><span>' . esc_html(translate($result->field_label, APP_TD)) . ':</span> ' . appthemes_make_clickable($post_meta_val) . '</li>';
                         // make_clickable is a WP function that auto hyperlinks urls
                     }
                 }
             }
         } elseif ($locationOption == 'content') {
             foreach ($results as $result) {
                 // now grab all ad fields and print out the field label and value
                 $post_meta_val = get_post_meta($postid, $result->field_name, true);
                 if (!empty($post_meta_val)) {
                     if ($result->field_name != 'cp_price' && $result->field_name != 'cp_currency' && $result->field_type == 'text area') {
                         echo '<div id="' . $result->field_name . '" class="custom-text-area dotted"><h3>' . esc_html(translate($result->field_label, APP_TD)) . '</h3>' . appthemes_make_clickable($post_meta_val) . '</div>';
                     }
                     // make_clickable is a WP function that auto hyperlinks urls
                 }
             }
         } else {
             // uncomment for debugging
             // echo 'Location Option Set: ' . $locationOption;
         }
     } else {
         _e('No ad details found.', APP_TD);
     }
 }
コード例 #5
0
ファイル: custom-forms.php プロジェクト: kalushta/darom
 function cp_get_ad_details($post_id, $category_id, $location = 'list')
 {
     $form_id = cp_get_form_id($category_id);
     $form_fields = cp_get_custom_form_fields($form_id);
     $post = get_post($post_id);
     if (!$post) {
         return;
     }
     if (!$form_fields) {
         _e('No ad details found.', APP_TD);
         return;
     }
     // allows to hook before ad details
     cp_action_before_ad_details($form_fields, $post, $location);
     foreach ($form_fields as $field) {
         // external plugins can modify or disable field
         $field = apply_filters('cp_ad_details_field', $field, $post, $location);
         if (!$field) {
             continue;
         }
         $disallow_fields = array('cp_price', 'cp_currency');
         if (in_array($field->field_name, $disallow_fields)) {
             continue;
         }
         $post_meta_val = get_post_meta($post->ID, $field->field_name, true);
         if (empty($post_meta_val)) {
             continue;
         }
         if ($location == 'list') {
             if ($field->field_type == 'text area') {
                 continue;
             }
             if ($field->field_type == 'checkbox') {
                 $post_meta_val = get_post_meta($post->ID, $field->field_name, false);
                 $post_meta_val = implode(", ", $post_meta_val);
             }
             $args = array('value' => $post_meta_val, 'label' => $field->field_label, 'id' => $field->field_name, 'class' => '');
             $args = apply_filters('cp_ad_details_' . $field->field_name, $args, $field, $post, $location);
             if ($args) {
                 echo '<li id="' . $args['id'] . '" class="' . $args['class'] . '"><span>' . esc_html(translate($args['label'], APP_TD)) . ':</span> ' . appthemes_make_clickable($args['value']) . '</li>';
             }
         } elseif ($location == 'content') {
             if ($field->field_type != 'text area') {
                 continue;
             }
             $args = array('value' => $post_meta_val, 'label' => $field->field_label, 'id' => $field->field_name, 'class' => 'custom-text-area dotted');
             $args = apply_filters('cp_ad_details_' . $field->field_name, $args, $field, $post, $location);
             if ($args) {
                 echo '<div id="' . $args['id'] . '" class="' . $args['class'] . '"><h3>' . esc_html(translate($args['label'], APP_TD)) . '</h3> ' . wpautop(appthemes_make_clickable($args['value'])) . '</div>';
             }
         }
     }
     // allows to hook after ad details
     cp_action_after_ad_details($form_fields, $post, $location);
 }
コード例 #6
0
ファイル: listing-single.php プロジェクト: kalushta/darom
 public function get_custom_form_fields()
 {
     // get the ad category ID
     $category_id = appthemes_get_custom_taxonomy($this->get_post_id(), APP_TAX_CAT, 'term_id');
     // get the form id based on category ID
     $form_id = !empty($category_id) ? cp_get_form_id($category_id) : false;
     $form_fields = cp_get_custom_form_fields($form_id);
     return $form_fields;
 }
コード例 #7
0
ファイル: tpl-edit-item.php プロジェクト: kalushta/darom
    _e('Edit the fields below and click save to update your ad. Your changes will be updated instantly on the site.', APP_TD);
    ?>
</p>

							<form name="mainform" id="mainform" class="form_edit" action="" method="post" enctype="multipart/form-data">

							<?php 
    wp_nonce_field('cp-edit-item');
    ?>

								<ol>

								<?php 
    // we first need to see if this ad is using a custom form
    // so lets search for a catid match and return the id if found
    $fid = cp_get_form_id($getad->term_id);
    // if there's no form id it must mean the default form is being used so let's go grab those fields
    if (!$fid) {
        // use this if there's no custom form being used and give us the default form
        $sql = "SELECT field_label, field_name, field_type, field_values, field_tooltip, field_req FROM {$wpdb->cp_ad_fields} WHERE field_core = '1' ORDER BY field_id asc";
    } else {
        // now we should have the formid so show the form layout based on the category selected
        $sql = $wpdb->prepare("SELECT f.field_label, f.field_name, f.field_type, f.field_values, f.field_perm, f.field_tooltip, m.meta_id, m.field_pos, m.field_req, m.form_id " . "FROM {$wpdb->cp_ad_fields} f " . "INNER JOIN {$wpdb->cp_ad_meta} m " . "ON f.field_id = m.field_id " . "WHERE m.form_id = %s " . "ORDER BY m.field_pos asc", $fid);
    }
    $results = $wpdb->get_results($sql);
    if ($results) {
        // build the edit ad form
        cp_formbuilder($results, $getad);
    }
    // check and make sure images are allowed
    if (get_option('cp_ad_images') == 'yes') {
コード例 #8
0
ファイル: views-checkout.php プロジェクト: kalushta/darom
 /**
  * Displays form.
  *
  * @param object $order
  * @param object $checkout
  *
  * return void
  */
 public function display($order, $checkout)
 {
     the_post();
     $listing = $this->get_listing_obj();
     $categories = wp_get_post_terms($listing->ID, APP_TAX_CAT);
     $this->category_id = !empty($categories) ? $categories[0]->term_id : false;
     $this->form_id = cp_get_form_id($this->category_id);
     $this->form_fields = cp_get_custom_form_fields($this->form_id);
     $checkout->add_data('listing_id', $listing->ID);
     $checkout->add_data('category_id', $this->category_id);
     $checkout->add_data('form_id', $this->form_id);
     appthemes_load_template('form-listing-edit.php', array('action' => $checkout->get_checkout_type(), 'listing' => $listing, 'category_id' => $this->category_id, 'form_id' => $this->form_id, 'form_fields' => $this->form_fields));
 }
コード例 #9
0
ファイル: functions.php プロジェクト: kalushta/darom
/**
 * 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;
}
コード例 #10
0
_e('Edit the fields below and click save to update your ad. Your changes will be updated instantly on the site.', APP_TD);
?>
</p>

						<form name="mainform" id="mainform" class="form_edit" action="" method="post" enctype="multipart/form-data">

						<?php 
wp_nonce_field('cp-edit-item');
?>

							<ol>

							<?php 
// we first need to see if this ad is using a custom form
// so lets search for a catid match and return the id if found
$fid = cp_get_form_id($category_id);
// if there's no form id it must mean the default form is being used so let's go grab those fields
if (!$fid) {
    // use this if there's no custom form being used and give us the default form
    $sql = "SELECT * FROM {$wpdb->cp_ad_fields} WHERE field_core = '1' ORDER BY field_id asc";
} else {
    // now we should have the formid so show the form layout based on the category selected
    $sql = $wpdb->prepare("SELECT * FROM {$wpdb->cp_ad_fields} f INNER JOIN {$wpdb->cp_ad_meta} m ON f.field_id = m.field_id WHERE m.form_id = %s ORDER BY m.field_pos asc", $fid);
}
$results = $wpdb->get_results($sql);
if ($results) {
    // build the edit ad form
    cp_formbuilder($results, $getad);
}
// check and make sure images are allowed
if ($cp_options->ad_images) {