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 }
/** * Prints a taxonomy field * * @param array $attr * @param int|null $post_id */ function taxonomy($attr, $post_id, $form_id) { $exclude_type = isset($attr['exclude_type']) ? $attr['exclude_type'] : 'exclude'; $exclude = $attr['exclude']; $taxonomy = $attr['name']; $class = ' wpuf_' . $attr['name'] . '_' . $form_id; $terms = array(); if ($post_id && $attr['type'] == 'text') { $terms = wp_get_post_terms($post_id, $taxonomy, array('fields' => 'names')); } elseif ($post_id) { $terms = wp_get_post_terms($post_id, $taxonomy, array('fields' => 'ids')); } $div_class = 'wpuf_' . $attr['name'] . '_' . $attr['type'] . '_' . $attr['id'] . '_' . $form_id; ?> <?php if ($attr['type'] == 'checkbox') { ?> <div class="wpuf-fields <?php echo $div_class; ?> " data-required="<?php echo esc_attr($attr['required']); ?> " data-type="tax-checkbox"> <?php } else { ?> <div class="wpuf-fields <?php echo $div_class; ?> "> <?php } ?> <?php switch ($attr['type']) { case 'ajax': $class = ' wpuf_' . $attr['name'] . '_' . $form_id; ?> <div class="category-wrap <?php echo $class; ?> "> <?php if (!count($terms)) { ?> <div id="lvl0" level="0"> <?php $this->taxnomy_select(null, $attr, $form_id); ?> </div> <?php } else { $level = 0; asort($terms); $last_term_id = end($terms); foreach ($terms as $term_id) { $class = $last_term_id != $term_id ? 'hasChild' : ''; ?> <div id="lvl<?php echo $level; ?> " level="<?php echo $level; ?> " > <?php $this->taxnomy_select($term_id, $attr); ?> </div> <?php $attr['parent_cat'] = $term_id; $level++; } } ?> </div> <span class="loading"></span> <?php break; case 'select': $selected = $terms ? $terms[0] : ''; $required = sprintf('data-required="%s" data-type="select"', $attr['required']); $select = wp_dropdown_categories(array('show_option_none' => __('-- Select --', 'wpuf'), 'hierarchical' => 1, 'hide_empty' => 0, 'orderby' => isset($attr['orderby']) ? $attr['orderby'] : 'name', 'order' => isset($attr['order']) ? $attr['order'] : 'ASC', 'name' => $taxonomy . '[]', 'taxonomy' => $taxonomy, 'echo' => 0, 'title_li' => '', 'class' => $taxonomy . $class, $exclude_type => $exclude, 'selected' => $selected)); echo str_replace('<select', '<select ' . $required, $select); break; case 'multiselect': $selected = $terms ? $terms : array(); $required = sprintf('data-required="%s" data-type="multiselect"', $attr['required']); $walker = new WPUF_Walker_Category_Multi(); $select = wp_dropdown_categories(array('hierarchical' => 1, 'hide_empty' => 0, 'orderby' => isset($attr['orderby']) ? $attr['orderby'] : 'name', 'order' => isset($attr['order']) ? $attr['order'] : 'ASC', 'name' => $taxonomy . '[]', 'id' => 'cat-ajax', 'taxonomy' => $taxonomy, 'echo' => 0, 'title_li' => '', 'class' => $taxonomy . ' multiselect' . $class, $exclude_type => $exclude, 'selected' => $selected, 'walker' => $walker)); echo str_replace('<select', '<select multiple="multiple" ' . $required, $select); break; case 'checkbox': wpuf_category_checklist($post_id, false, $attr, $class); break; case 'text': ?> <input class="textfield<?php echo $this->required_class($attr); ?> " id="<?php echo $attr['name']; ?> " type="text" data-required="<?php echo $attr['required']; ?> " data-type="text"<?php $this->required_html5($attr); ?> name="<?php echo esc_attr($attr['name']); ?> " value="<?php echo esc_attr(implode(', ', $terms)); ?> " size="40" /> <script type="text/javascript"> jQuery(function($) { $('#<?php echo $attr['name']; ?> ').suggest( wpuf_frontend.ajaxurl + '?action=ajax-tag-search&tax=<?php echo $attr['name']; ?> ', { delay: 500, minchars: 2, multiple: true, multipleSep: ', ' } ); }); </script> <?php break; default: # code... break; } ?> <span class="wpuf-help"><?php echo stripslashes($attr['help']); ?> </span> </div> <?php }
/** * Prints a taxonomy field * * @param array $attr * @param int|null $post_id */ function taxonomy($attr, $post_id) { $exclude_type = isset($attr['exclude_type']) ? $attr['exclude_type'] : 'exclude'; $exclude = $attr['exclude']; $taxonomy = $attr['name']; $terms = array(); if ($post_id && $attr['type'] == 'text') { $terms = wp_get_post_terms($post_id, $taxonomy, array('fields' => 'names')); } elseif ($post_id) { $terms = wp_get_post_terms($post_id, $taxonomy, array('fields' => 'ids')); } ?> <div class="wpuf-fields"> <?php switch ($attr['type']) { case 'select': $selected = $terms ? $terms[0] : ''; $required = sprintf('data-required="%s" data-type="select"', $attr['required']); $select = wp_dropdown_categories(array('show_option_none' => __('-- Select --', 'wpuf'), 'hierarchical' => 1, 'hide_empty' => 0, 'orderby' => isset($attr['orderby']) ? $attr['orderby'] : 'name', 'order' => isset($attr['order']) ? $attr['order'] : 'ASC', 'name' => $taxonomy . '[]', 'id' => $taxonomy, 'taxonomy' => $taxonomy, 'echo' => 0, 'title_li' => '', 'class' => $taxonomy, $exclude_type => $exclude, 'selected' => $selected)); echo str_replace('<select', '<select ' . $required, $select); break; case 'multiselect': $selected = $terms ? $terms : array(); $required = sprintf('data-required="%s" data-type="multiselect"', $attr['required']); $walker = new WPUF_Walker_Category_Multi(); $select = wp_dropdown_categories(array('show_option_none' => __('-- Select --', 'wpuf'), 'hierarchical' => 1, 'hide_empty' => 0, 'orderby' => isset($attr['orderby']) ? $attr['orderby'] : 'name', 'order' => isset($attr['order']) ? $attr['order'] : 'ASC', 'name' => $taxonomy . '[]', 'id' => $taxonomy, 'taxonomy' => $taxonomy, 'echo' => 0, 'title_li' => '', 'class' => $taxonomy . ' multiselect', $exclude_type => $exclude, 'selected' => $selected, 'walker' => $walker)); echo str_replace('<select', '<select multiple="multiple" ' . $required, $select); break; case 'checkbox': printf('<span data-required="%s" data-type="tax-checkbox" />', $attr['required']); wpuf_category_checklist($post_id, false, $attr); break; case 'text': ?> <input class="textfield<?php echo $this->required_class($attr); ?> " id="<?php echo $attr['name']; ?> " type="text" data-required="<?php echo $attr['required']; ?> " data-type="text"<?php $this->required_html5($attr); ?> name="<?php echo esc_attr($attr['name']); ?> " value="<?php echo esc_attr(implode(', ', $terms)); ?> " size="40" /> <script type="text/javascript"> jQuery(function($) { $('#<?php echo $attr['name']; ?> ').suggest( wpuf_frontend.ajaxurl + '?action=ajax-tag-search&tax=<?php echo $attr['name']; ?> ', { delay: 500, minchars: 2, multiple: true, multipleSep: ', ' } ); }); </script> <?php break; default: # code... break; } ?> <span class="wpuf-help"><?php echo $attr['help']; ?> </span> </div> <?php }
function show_front_publisher($atts) { global $wpdb, $xoouserultra; require_once ABSPATH . 'wp-includes/general-template.php'; $cat_type = 'normal'; $exclude = ""; $editor_id = 'uultra_post_content'; $content = ''; $html = ""; //control total amount of posts $user_id = get_current_user_id(); $max_allowed_posts = $this->get_max_allowed_posts(); $user_post_count = $this->count_user_posts_by_type($user_id); ?> <div class="commons-panel xoousersultra-shadow-borers" > <div class="commons-panel-heading"> <h2> <?php echo __('Add New Post', 'xoousers'); ?> </h2> </div> <div class="commons-panel-content" > <div class="uultra-post-publish"> <div class='uupublic-ultra-info'><?php echo __('Max Allowed Posts: ', 'xoousers'); ?> <?php echo $max_allowed_posts; ?> , <?php echo __('You have posted: ' . $user_post_count . ' already ', 'xoousers'); ?> </div> <?php if ($this->act_message != "") { echo "<div class='uupublic-ultra-success'>" . $this->act_message . "</div>"; } if ($this->act_limits != "") { echo "<div class='uupublic-ultra-error'>" . $this->act_limits . "</div>"; } ?> <form method="post" name="uultra-front-publisher-post"> <input type="hidden" name="uultra-conf-publisher-post" value="ok" enctype="multipart/form-data"/> <div class="tablenav_post"> <p><a class="uultra-btn-commm" href="?module=posts" title="<?php echo __('Add New Post', 'xoousers'); ?> " ><span><i class="fa fa-angle-double-left fa-lg"></i></span> Back </a></p> </div> <div class="field_row"> <p><?php echo __('Title:', 'xoousers'); ?> </p> <p><input name="uultra_post_title" type="text" class="xoouserultra-input" /></p> </div> <?php if ($xoouserultra->get_option('uultra_front_publisher_allows_category') != 'no') { ?> <div class="field_row"> <p><?php echo __('Category:', 'xoousers'); ?> </p> <p> <?php if ($cat_type == 'normal') { wp_dropdown_categories('show_option_none=' . __('-- Select --', 'xoousers') . '&hierarchical=1&hide_empty=0&orderby=name&name=uultra_category[]&id=uultra_category&show_count=0&title_li=&use_desc_for_title=1&class=xoouserultra-input requiredField&exclude=' . $exclude); } else { if ($cat_type == 'ajax') { wp_dropdown_categories('show_option_none=' . __('-- Select --', 'xoousers') . '&hierarchical=1&hide_empty=0&orderby=name&name=uultra_category[]&id=uultra_category-ajax&show_count=0&title_li=&use_desc_for_title=1&class=cat requiredField&depth=1&exclude=' . $exclude); } else { wpuf_category_checklist(0, false, 'uultra_category', $exclude); } } ?> </p> </div> <?php } ?> <div class="field_row"> <p><?php echo __('Post Photos:', 'xoousers'); ?> </p> </div> <div class="pr_post_images"> <?php echo $this->get_post_photo_uploader(); ?> <div id="uuultra_filelist_uploaded" class="uultra-post-plist"> <ul></ul> </div> </div> <p><?php echo __('Description:', 'xoousers'); ?> </p> <?php $editor_settings = array('media_buttons' => false, 'textarea_rows' => 15, 'teeny' => true); wp_editor($content, $editor_id, $editor_settings); ?> <div class="field_row"> <p><?php echo __('Tags:', 'xoousers'); ?> </p> <p><input name="uultra_post_tags" type="text" class="xoouserultra-input" /></p> </div> <div class="field_row"> <p><input type="submit" name="xoouserultra-submit-post" class="xoouserultra-button" value="<?php echo __('Submit', 'xoousers'); ?> "></p> </div> </form> </div> </div> </div> <!-- End post wrapper--> <?php }
/** * Add posting main form * * @param $post_type */ function post_form($post_type) { global $userdata; $userdata = get_user_by('id', $userdata->ID); if (isset($_POST['wpuf_post_new_submit'])) { $nonce = $_REQUEST['_wpnonce']; if (!wp_verify_nonce($nonce, 'wpuf-add-post')) { wp_die(__('Cheating?')); } $this->submit_post(); } $info = __("Post It!", 'wpuf'); $can_post = 'yes'; $info = apply_filters('wpuf_addpost_notice', $info); $can_post = apply_filters('wpuf_can_post', $can_post); $featured_image = wpuf_get_option('enable_featured_image', 'wpuf_frontend_posting', 'no'); $title = isset($_POST['wpuf_post_title']) ? esc_attr($_POST['wpuf_post_title']) : ''; $description = isset($_POST['wpuf_post_content']) ? $_POST['wpuf_post_content'] : ''; if ($can_post == 'yes') { ?> <div id="wpuf-post-area"> <form id="wpuf_new_post_form" name="wpuf_new_post_form" action="" enctype="multipart/form-data" method="POST"> <?php wp_nonce_field('wpuf-add-post'); ?> <ul class="wpuf-post-form"> <?php do_action('wpuf_add_post_form_top', $post_type); //plugin hook ?> <?php wpuf_build_custom_field_form('top'); ?> <?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', 'wpuf_frontend_posting', 'Featured Image'); ?> </label> <div id="wpuf-ft-upload-container"> <div id="wpuf-ft-upload-filelist"></div> <a id="wpuf-ft-upload-pickfiles" class="button" href="#"><?php echo wpuf_get_option('ft_image_btn_label', 'wpuf_frontend_posting', 'Upload Image'); ?> </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', 'wpuf_labels', 'Post Title'); ?> <span class="required">*</span> </label> <input class="requiredField" type="text" value="<?php echo $title; ?> " name="wpuf_post_title" id="new-post-title" minlength="2"> <div class="clear"></div> <p class="description"><?php echo stripslashes(wpuf_get_option('title_help', 'wpuf_labels')); ?> </p> </li> <?php if (wpuf_get_option('allow_cats', 'wpuf_frontend_posting', 'on') == 'on') { ?> <li> <label for="new-post-cat"> <?php echo wpuf_get_option('cat_label', 'wpuf_labels', 'Category'); ?> <span class="required">*</span> </label> <div class="category-wrap" style="float:left;"> <div id="lvl0"> <?php $exclude = wpuf_get_option('exclude_cats', 'wpuf_frontend_posting'); $cat_type = wpuf_get_option('cat_type', 'wpuf_frontend_posting', 'normal'); 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); } 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); } else { wpuf_category_checklist(0, false, 'category', $exclude); } } ?> </div> </div> <div class="loading"></div> <div class="clear"></div> <p class="description"><?php echo stripslashes(wpuf_get_option('cat_help', 'wpuf_labels')); ?> </p> </li> <?php } ?> <?php do_action('wpuf_add_post_form_description', $post_type); ?> <?php wpuf_build_custom_field_form('description'); ?> <li> <label for="new-post-desc"> <?php echo wpuf_get_option('desc_label', 'wpuf_labels', 'Post Content'); ?> <span class="required">*</span> </label> <?php $editor = wpuf_get_option('editor_type', 'wpuf_frontend_posting'); if ($editor == 'full') { ?> <div style="float:left;"> <?php wp_editor($description, '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($description, '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($description); ?> </textarea> <?php } } ?> <div class="clear"></div> <p class="description"><?php echo stripslashes(wpuf_get_option('desc_help', 'wpuf_labels')); ?> </p> </li> <?php do_action('wpuf_add_post_form_after_description', $post_type); $this->publish_date_form(); $this->expiry_date_form(); wpuf_build_custom_field_form('tag'); if (wpuf_get_option('allow_tags', 'wpuf_frontend_posting', 'on') == 'on') { ?> <li> <label for="new-post-tags"> <?php echo wpuf_get_option('tag_label', 'wpuf_labels', 'Tags'); ?> </label> <input type="text" name="wpuf_post_tags" id="new-post-tags" class="new-post-tags"> <p class="description"><?php echo stripslashes(wpuf_get_option('tag_help', 'wpuf_labels')); ?> </p> <div class="clear"></div> </li> <?php } do_action('wpuf_add_post_form_tags', $post_type); wpuf_build_custom_field_form('bottom'); ?> <li> <label> </label> <input class="wpuf_submit" type="submit" name="wpuf_new_post_submit" value="<?php echo esc_attr(wpuf_get_option('submit_label', 'wpuf_labels', 'Submit')); ?> "> <input type="hidden" name="wpuf_post_type" value="<?php echo $post_type; ?> " /> <input type="hidden" name="wpuf_post_new_submit" value="yes" /> </li> <?php do_action('wpuf_add_post_form_bottom', $post_type); ?> </ul> </form> </div> <?php } else { echo '<div class="info">' . $info . '</div>'; } }