Пример #1
0
/**
 * Add posting main form
 *
 * @author Tareq Hasan
 * @package WP User Frontend
 *
 * @param $post_type
 */
function wpuf_pending_post($post_type)
{
    global $userdata;
    $userdata = get_userdata($userdata->ID);
    $info = __("Post It!", 'wpuf');
    $can_post = 'yes';
    $info = apply_filters('wpuf_addpost_notice', $info);
    $can_post = apply_filters('wpuf_can_post', $can_post);
    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');
        ?>

                    <li>
                        <label for="new-post-title">
                            <?php 
        echo get_option('wpuf_title_label');
        ?>
 <span class="required">*</span>
                        </label>
                        <input class="requiredField" type="text" name="wpuf_post_title" id="new-post-title" minlength="2">
                        <div class="clear"></div>
                        <p class="description"><?php 
        echo stripslashes(get_option('wpuf_title_help'));
        ?>
</p>
                    </li>

                    <?php 
        if (get_option('wpuf_allow_choose_cat') == 'yes') {
            ?>
                        <li>
                            <label for="new-post-cat">
                                <?php 
            echo get_option('wpuf_cat_label');
            ?>
 <span class="required">*</span>
                            </label>
                            <div style="float:left;">
                                <div id="catlvl0">
                                    <?php 
            $exclude = get_option('wpuf_exclude_cat');
            ?>
                                    <?php 
            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&depth=1&exclude=' . $exclude);
            ?>
                                </div>
                            </div>
                            <div id="categories-footer" style="float:left;"></div>
                            <div class="clear"></div>
                            <p class="description"><?php 
            echo stripslashes(get_option('wpuf_cat_help'));
            ?>
</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 get_option('wpuf_desc_label');
        ?>
 <span class="required">*</span>
                        </label>
                        <div style="float:left;">
                            <?php 
        if (get_option('wpuf_editor_type') == 'rich') {
            ?>
                                <?php 
            wp_editor('', 'new-post-desc', array('textarea_name' => 'wpuf_post_content', 'teeny' => true, 'textarea_rows' => 8));
            ?>
                            <?php 
        } else {
            ?>
                                <textarea name="wpuf_post_content" id="new-post-desc" cols="60" rows="8"></textarea>
                            <?php 
        }
        ?>
                        </div>
                        <div class="clear"></div>
                        <p class="description"><?php 
        echo stripslashes(get_option('wpuf_desc_help'));
        ?>
</p>
                    </li>

                    <?php 
        do_action('wpuf_add_post_form_after_description', $post_type);
        ?>
                    <?php 
        wpuf_build_custom_field_form('tag');
        ?>

                    <?php 
        if (get_option('wpuf_allow_tags') == 'yes') {
            ?>
                        <li>
                            <label for="new-post-tags">
                                <?php 
            echo get_option('wpuf_tag_label');
            ?>
                            </label>
                            <input type="text" name="wpuf_post_tags" id="new-post-tags" class="new-post-tags">
                            <p class="description"><?php 
            echo stripslashes(get_option('wpuf_tag_help'));
            ?>
</p>
                            <div class="clear"></div>
                        </li>
                    <?php 
        }
        ?>

                    <?php 
        do_action('wpuf_add_post_form_tags', $post_type);
        ?>

                    <?php 
        wpuf_attachment_fields();
        ?>

                    <?php 
        wpuf_build_custom_field_form('bottom');
        ?>

                    <li>
                        <label>&nbsp;</label>
                        <input class="wpuf_submit" type="submit" name="wpuf_new_post_submit" value="Proposer un projet">
                        <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>';
    }
}
Пример #2
0
function wpuf_edit_show_form($post)
{
    $post_tags = wp_get_post_tags($post->ID);
    $tagsarray = array();
    foreach ($post_tags as $tag) {
        $tagsarray[] = $tag->name;
    }
    $tagslist = implode(', ', $tagsarray);
    $categories = get_the_category($post->ID);
    ?>
    <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', $post->post_type, $post);
    //plugin hook
    ?>
            <?php 
    wpuf_build_custom_field_form('top', true, $post->ID);
    ?>

            <li>
                <label for="new-post-title">
                    <?php 
    echo get_option('wpuf_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($post->post_title);
    ?>
">
                <div class="clear"></div>
            </li>

            <?php 
    if (get_option('wpuf_allow_choose_cat') == 'yes') {
        ?>
                <li>
                    <label for="new-post-cat">
                        <?php 
        echo get_option('wpuf_cat_label');
        ?>
 <span class="required">*</span>
                    </label>
                    <?php 
        $exclude = get_option('wpuf_exclude_cat');
        $cats = get_the_category($post->ID);
        $selected = 0;
        if ($cats) {
            $selected = $cats[0]->term_id;
        }
        ?>
                    <?php 
        wp_dropdown_categories('show_option_none=' . __('-- Select --', 'wpuf') . '&hierarchical=1&hide_empty=0&orderby=id&show_count=0&title_li=&use_desc_for_title=1&class=cat requiredField&exclude=' . $exclude . '&selected=' . $selected);
        ?>
                    <div class="clear"></div>
                    <p class="description"><?php 
        echo stripslashes(get_option('wpuf_cat_help'));
        ?>
</p>
                </li>
            <?php 
    }
    ?>

            <?php 
    do_action('wpuf_add_post_form_description', $post->post_type, $post);
    ?>
            <?php 
    wpuf_build_custom_field_form('description', true, $post->ID);
    ?>

            <li>
                <label for="new-post-desc">
                    <?php 
    echo get_option('wpuf_desc_label');
    ?>
 <span class="required">*</span>
                </label>
                <div style="float:left;">
                    <?php 
    if (get_option('wpuf_editor_type') == 'rich') {
        ?>
                        <?php 
        wp_editor($post->post_content, 'new-post-desc', array('textarea_name' => 'wpuf_post_content', 'teeny' => true, 'textarea_rows' => 8));
        ?>
                    <?php 
    } else {
        ?>
                        <textarea name="wpuf_post_content" id="new-post-desc" cols="60" rows="8"><?php 
        echo esc_textarea($post->post_content);
        ?>
</textarea>
                    <?php 
    }
    ?>
                </div>
                <div class="clear"></div>
            </li>

            <?php 
    do_action('wpuf_add_post_form_after_description', $post->post_type, $post);
    ?>
            <?php 
    wpuf_build_custom_field_form('tag', true, $post->ID);
    ?>

            <?php 
    if (get_option('wpuf_allow_tags') == 'yes') {
        ?>
                <li>
                    <label for="new-post-tags">
                        <?php 
        echo get_option('wpuf_tag_label');
        ?>
                    </label>
                    <input type="text" name="wpuf_post_tags" id="new-post-tags" value="<?php 
        echo $tagslist;
        ?>
">
                    <div class="clear"></div>
                </li>
            <?php 
    }
    ?>

            <?php 
    wpuf_attachment_fields(true, $post->ID);
    ?>

            <?php 
    do_action('wpuf_add_post_form_tags', $post->post_type, $post);
    ?>
            <?php 
    wpuf_build_custom_field_form('bottom', true, $post->ID);
    ?>

            <li>
                <label>&nbsp;</label>
                <input class="wpuf_submit" type="submit" name="wpuf_edit_post_submit" value="<?php 
    echo esc_attr(get_option('wpuf_post_update_label', 'Update Post!'));
    ?>
">
                <input type="hidden" name="wpuf_edit_post_submit" value="yes" />
                <input type="hidden" name="post_id" value="<?php 
    echo $post->ID;
    ?>
">
            </li>
        </ul>
    </form>

    <?php 
    if (get_option('wpuf_allow_attachments') == 'yes') {
        ?>
        <div class="wpuf-edit-attachment">
            <?php 
        wpuf_edit_attachment($post->ID);
        ?>
        </div>
    <?php 
    }
}