function add_post_fields($post_type, $post_obj = null) { //var_dump($post_type, $post_obj); $attachments = array(); if ($post_obj) { $attachments = auiu_get_attachments($post_obj->ID); } ?> <li> <label><?php echo auiu_get_option('attachment_label', 'auiu_labels', 'Attachments'); ?> </label> <div class="clear"></div> </li> <li> <div id="auiu-attachment-upload-container"> <div id="auiu-attachment-upload-filelist"> <ul class="auiu-attachment-list"> <script>window.auiuFileCount = 0;</script> <?php if ($attachments) { foreach ($attachments as $attach) { echo $this->attach_html($attach['id']); echo '<script>window.auiuFileCount += 1;</script>'; } } ?> </ul> </div> <a id="auiu-attachment-upload-pickfiles" class="button" href="#"><?php echo auiu_get_option('attachment_btn_label', 'auiu_labels', 'Add another'); ?> </a> </div> <div class="clear"></div> </li> <?php }
/** * Shows the custom field data and attachments to the post * * @global object $wpdb * @global object $post * @param string $content * @return string */ function auiu_show_meta_front($content) { global $wpdb, $post; //check, if custom field is enabled $enabled = auiu_get_option('enable_custom_field', 'auiu_frontend_posting'); $show_custom = auiu_get_option('cf_show_front', 'auiu_others'); $show_attachment = auiu_get_option('att_show_front', 'auiu_others'); if ($enabled == 'on' && $show_custom == 'on') { $extra = ''; $fields = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}auiu_customfields ORDER BY `region` DESC", OBJECT); if ($wpdb->num_rows > 0) { $extra .= '<ul class="auiu_customs">'; foreach ($fields as $field) { $meta = get_post_meta($post->ID, $field->field, true); if ($meta) { $extra .= sprintf('<li><label>%s</label> : %s</li>', $field->label, make_clickable($meta)); } } $extra .= '<ul>'; $content .= $extra; } } if ($show_attachment == 'on') { $attach = ''; $attachments = auiu_get_attachments($post->ID); if ($attachments) { $attach = '<ul class="auiu-attachments">'; foreach ($attachments as $file) { //if the attachment is image, show the image. else show the link if (auiu_is_file_image($file['url'], $file['mime'])) { $thumb = wp_get_attachment_image_src($file['id']); $attach .= sprintf('<li><a href="%s"><img src="%s" alt="%s" /></a></li>', $file['url'], $thumb[0], esc_attr($file['title'])); } else { $attach .= sprintf('<li><a href="%s" title="%s">%s</a></li>', $file['url'], esc_attr($file['title']), $file['title']); } } $attach .= '</ul>'; } if ($attach) { $content .= $attach; } } return $content; }