/** * Upload Featured image via ajax * * @since 0.8 */ function featured_img_upload() { check_ajax_referer('wpuf_featured_img', 'nonce'); $upload_data = array('name' => $_FILES['wpuf_featured_img']['name'], 'type' => $_FILES['wpuf_featured_img']['type'], 'tmp_name' => $_FILES['wpuf_featured_img']['tmp_name'], 'error' => $_FILES['wpuf_featured_img']['error'], 'size' => $_FILES['wpuf_featured_img']['size']); $attach_id = wpuf_upload_file($upload_data); if ($attach_id) { $html = wpuf_feat_img_html($attach_id); $response = array('success' => true, 'html' => $html); echo json_encode($response); exit; } $response = array('success' => false); echo json_encode($response); exit; }
function edit_form($curpost) { $post_tags = wp_get_post_tags($curpost->ID); $tagsarray = array(); foreach ($post_tags as $tag) { $tagsarray[] = $tag->name; } $tagslist = implode(', ', $tagsarray); $categories = get_the_category($curpost->ID); $featured_image = wpuf_get_option('enable_featured_image'); ?> <div id="wpuf-post-area"> <form name="wpuf_edit_post_form" id="wpuf_edit_post_form" action="" enctype="multipart/form-data" method="POST"> <?php wp_nonce_field('wpuf-edit-post'); ?> <ul class="wpuf-post-form"> <?php do_action('wpuf_add_post_form_top', $curpost->post_type, $curpost); //plugin hook ?> <?php wpuf_build_custom_field_form('top', true, $curpost->ID); ?> <?php if ($featured_image == 'yes') { ?> <?php if (current_theme_supports('post-thumbnails')) { ?> <li> <label for="post-thumbnail"><?php echo wpuf_get_option('ft_image_label'); ?> </label> <div id="wpuf-ft-upload-container"> <div id="wpuf-ft-upload-filelist"> <?php $style = ''; if (has_post_thumbnail($curpost->ID)) { $style = ' style="display:none"'; $post_thumbnail_id = get_post_thumbnail_id($curpost->ID); echo wpuf_feat_img_html($post_thumbnail_id); } ?> </div> <a id="wpuf-ft-upload-pickfiles" class="button" href="#"><?php echo wpuf_get_option('ft_image_btn_label'); ?> </a> </div> <div class="clear"></div> </li> <?php } else { ?> <div class="info"><?php _e('Your theme doesn\'t support featured image', 'wpuf'); ?> </div> <?php } ?> <?php } ?> <li> <label for="new-post-title"> <?php echo wpuf_get_option('title_label'); ?> <span class="required">*</span> </label> <input type="text" name="wpuf_post_title" id="new-post-title" minlength="2" value="<?php echo esc_html($curpost->post_title); ?> "> <div class="clear"></div> <p class="description"><?php echo stripslashes(wpuf_get_option('title_help')); ?> </p> </li> <?php if (wpuf_get_option('allow_cats') == 'on') { ?> <li> <label for="new-post-cat"> <?php echo wpuf_get_option('cat_label'); ?> <span class="required">*</span> </label> <?php $exclude = wpuf_get_option('exclude_cats'); $cat_type = wpuf_get_option('cat_type'); $cats = get_the_category($curpost->ID); $selected = 0; if ($cats) { $selected = $cats[0]->term_id; } //var_dump( $cats ); //var_dump( $selected ); ?> <div class="category-wrap" style="float:left;"> <div id="lvl0"> <?php if ($cat_type == 'normal') { wp_dropdown_categories('show_option_none=' . __('-- Select --', 'wpuf') . '&hierarchical=1&hide_empty=0&orderby=name&name=category[]&id=cat&show_count=0&title_li=&use_desc_for_title=1&class=cat requiredField&exclude=' . $exclude . '&selected=' . $selected); } else { if ($cat_type == 'ajax') { wp_dropdown_categories('show_option_none=' . __('-- Select --', 'wpuf') . '&hierarchical=1&hide_empty=0&orderby=name&name=category[]&id=cat-ajax&show_count=0&title_li=&use_desc_for_title=1&class=cat requiredField&depth=1&exclude=' . $exclude . '&selected=' . $selected); } else { wpuf_category_checklist($curpost->ID); } } ?> </div> </div> <div class="loading"></div> <div class="clear"></div> <p class="description"><?php echo stripslashes(wpuf_get_option('cat_help')); ?> </p> </li> <?php } ?> <?php do_action('wpuf_add_post_form_description', $curpost->post_type, $curpost); ?> <?php wpuf_build_custom_field_form('description', true, $curpost->ID); ?> <li> <label for="new-post-desc"> <?php echo wpuf_get_option('desc_label'); ?> <span class="required">*</span> </label> <?php $editor = wpuf_get_option('editor_type'); if ($editor == 'full') { ?> <div style="float:left;"> <?php wp_editor($curpost->post_content, 'new-post-desc', array('textarea_name' => 'wpuf_post_content', 'editor_class' => 'requiredField', 'teeny' => false, 'textarea_rows' => 8)); ?> </div> <?php } else { if ($editor == 'rich') { ?> <div style="float:left;"> <?php wp_editor($curpost->post_content, 'new-post-desc', array('textarea_name' => 'wpuf_post_content', 'editor_class' => 'requiredField', 'teeny' => true, 'textarea_rows' => 8)); ?> </div> <?php } else { ?> <textarea name="wpuf_post_content" class="requiredField" id="new-post-desc" cols="60" rows="8"><?php echo esc_textarea($curpost->post_content); ?> </textarea> <?php } } ?> <div class="clear"></div> <p class="description"><?php echo stripslashes(wpuf_get_option('desc_help')); ?> </p> </li> <?php do_action('wpuf_add_post_form_after_description', $curpost->post_type, $curpost); ?> <?php wpuf_build_custom_field_form('tag', true, $curpost->ID); ?> <?php if (wpuf_get_option('allow_tags') == 'on') { ?> <li> <label for="new-post-tags"> <?php echo wpuf_get_option('tag_label'); ?> </label> <input type="text" name="wpuf_post_tags" id="new-post-tags" value="<?php echo $tagslist; ?> "> <p class="description"><?php echo stripslashes(wpuf_get_option('tag_help')); ?> </p> <div class="clear"></div> </li> <?php } ?> <?php do_action('wpuf_add_post_form_tags', $curpost->post_type, $curpost); ?> <?php wpuf_build_custom_field_form('bottom', true, $curpost->ID); ?> <li> <label> </label> <input class="wpuf_submit" type="submit" name="wpuf_edit_post_submit" value="<?php echo esc_attr(wpuf_get_option('update_label')); ?> "> <input type="hidden" name="wpuf_edit_post_submit" value="yes" /> <input type="hidden" name="post_id" value="<?php echo $curpost->ID; ?> "> </li> </ul> </form> </div> <?php }