function add_post_fields($post_type, $post_obj = null)
    {
        //var_dump($post_type, $post_obj);
        $attachments = array();
        if ($post_obj) {
            $attachments = wpfu_get_attachments($post_obj->ID);
        }
        ?>
        <li>
            <label><?php 
        echo wpuf_get_option('attachment_label', 'wpuf_labels', 'Attachments');
        ?>
</label>
            <div class="clear"></div>
        </li>
        <li>
            <div id="wpuf-attachment-upload-container">
                <div id="wpuf-attachment-upload-filelist">
                    <ul class="wpuf-attachment-list">
                        <script>window.wpufFileCount = 0;</script>
                        <?php 
        if ($attachments) {
            foreach ($attachments as $attach) {
                echo $this->attach_html($attach['id']);
                echo '<script>window.wpufFileCount += 1;</script>';
            }
        }
        ?>
                    </ul>
                </div>
                <a id="wpuf-attachment-upload-pickfiles" class="button" href="#"><?php 
        echo wpuf_get_option('attachment_btn_label', 'wpuf_labels', 'Add another');
        ?>
</a>
            </div>
            <div class="clear"></div>
        </li>
        <?php 
    }
예제 #2
0
/**
 * Shows the custom field data and attachments to the post
 *
 * @since 0.7
 *
 * @global object $wpdb
 * @global object $post
 * @param string $content
 * @return string
 */
function wpuf_show_meta_front($content)
{
    global $wpdb, $post;
    //check, if custom field is enabled
    $enabled = wpuf_get_option('enable_custom_field');
    $show_custom = wpuf_get_option('cf_show_front');
    $show_attachment = wpuf_get_option('att_show_front');
    if ($enabled == 'on' && $show_custom == 'on') {
        $extra = '';
        $fields = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}wpuf_customfields ORDER BY `region` DESC", OBJECT);
        if ($wpdb->num_rows > 0) {
            $extra .= '<ul class="wpuf_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 = wpfu_get_attachments($post->ID);
        if ($attachments) {
            $attach = '<ul class="wpuf-attachments">';
            foreach ($attachments as $file) {
                //if the attachment is image, show the image. else show the link
                if (wpuf_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;
}