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);
 }
コード例 #2
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);
 }
コード例 #3
0
            _e('Phone:', 'appthemes');
            ?>
</span> <?php 
            echo get_post_meta($post->ID, 'phone', true);
            ?>
</li>

                                            <?php 
            if (get_post_meta($post->ID, 'cp_adURL', true)) {
            }
            ?>
                                                <li><span><?php 
            _e('URL:', 'appthemes');
            ?>
</span> <?php 
            echo appthemes_make_clickable(get_post_meta($post->ID, 'cp_adURL', true));
            ?>
</li>
											<li>&nbsp;</li>
                                            <li><span><?php 
            _e('Listed:', 'appthemes');
            ?>
</span> <?php 
            the_time(get_option('date_format') . ' ' . get_option('time_format'));
            ?>
</li>
                                            <li><span><?php 
            _e('Expires:', 'appthemes');
            ?>
</span><?php 
            _e('Expires:', 'appthemes');
コード例 #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);
     }
 }