Advertisement
Guest User

Untitled

a guest
Mar 13th, 2011
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.85 KB | None | 0 0
  1. <?php
  2.  
  3.     /* Template Name: New Post */
  4.  
  5.    
  6.     if(isset($_POST['new_post']) == '1')
  7.     {
  8.         $post_title = $_POST['post_title'];
  9.  
  10.         $post_content = $_POST['post_content'];
  11.        
  12.         $post_category = $_POST['post_category'];
  13.        
  14.         $post_tags = $_POST['post_tags'];
  15.        
  16.         $post_url = $_POST['post_url'];
  17.        
  18.         $post_code = $_POST['post_code'];
  19.        
  20.         $post_public = $_POST['post_public'];
  21.        
  22.         $new_post = array(
  23.               'ID' => '',
  24.               'post_author' => $user->ID,
  25.               'post_type' => 'posts',
  26.               'post_content' => $post_content,
  27.               'post_title' => $post_title,
  28.               'post_status' => 'publish',
  29.               'tax_input' => array('posts_category' => $post_category, 'posts_tags' => $post_tags)
  30.             );
  31.    
  32.         $post_id = wp_insert_post($new_post);
  33.        
  34.         add_post_meta( $post_id, 'post_url', $post_url, true );
  35.        
  36.         add_post_meta( $post_id, 'post_code', $post_code, true );
  37.        
  38.         add_post_meta( $post_id, 'post_public', $post_public, true );
  39.  
  40.         // This will redirect you to the newly created post
  41.         $post = get_post($post_id); wp_redirect($post->guid);
  42.     }
  43.  
  44.     get_header();
  45.  
  46. ?>
  47.  
  48. <script type="text/javascript">
  49.  
  50.     jQuery(document).ready(function($)
  51.     {
  52.         $("input[name='post_category']").change(function()
  53.         {
  54.                 $("#discussion-label").toggle(this.value == "12");
  55.         });
  56.         $("input[name='post_category']").change(function()
  57.         {
  58.                 $("#code-container").toggle(this.value == "13");
  59.                 $("#code-label").toggle(this.value == "13");
  60.         });
  61.         $("input[name='post_category']").change(function()
  62.         {
  63.                 $("#link-container").toggle(this.value == "14");
  64.                 $("#link-label").toggle(this.value == "14");
  65.         });
  66.        
  67.         $("input#r1:checked").change();
  68.         $("input#r3:checked").change();
  69.         $("input#r4:checked").change();
  70.     });
  71.  
  72. </script>
  73.  
  74.     <div id="maincontent">
  75.         <div id="fade">
  76.             <div class="wrapper clearfix">
  77.            
  78.                 <div id="sidebar" class="clearfix">
  79.                
  80.                     <div class="widget clearfix">
  81.                         <h3>CreatHive Guidelines</h3>
  82.                         <p>First time posting? Make sure to read the <a title="Community Guidelines" href="<?php bloginfo('url'); ?>/guidelines">guidelines</a> first.</p>
  83.                     </div>
  84.                    
  85.                     <div class="widget clearfix">
  86.                         <h3>Test</h3>
  87.                         <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
  88.                     </div>
  89.                
  90.                 </div>
  91.        
  92.                 <div id="content" class="clearfix">
  93.                
  94.                     <div class="page-header clearfix">
  95.                    
  96.                         <h1 class="title posts">Post something on CreatHive</h1>
  97.                        
  98.                     </div>
  99.                    
  100.                     <script src="<?php bloginfo('template_directory'); ?>/js/jquery.maxlength.js" type="text/javascript"></script>
  101.                    
  102.                     <form method="post" action="" id="postform">   
  103.                     <fieldset id="post-form">                      
  104.                         <ul>
  105.                             <li>
  106.                                 <div class="radio-list clearfix">
  107.                                 <ul>
  108.                                     <li><label for="r1"><input type="radio" name="post_category" id="r1" value="12" checked="checked" /> Share an Article</label></li>
  109.                                     <li><label for="r3"><input type="radio" name="post_category" id="r3" value="13" /> Share some Code</label></li>
  110.                                     <li><label for="r4"><input type="radio" name="post_category" id="r4" value="14" /> Share a Link</label></li>
  111.                                 </ul>
  112.                                 </div>
  113.                             </li>
  114.                             <li>
  115.                                 <label for="post_title">Title <span>make it short and sweet, <span class="charsRemaining"></span> characters</span></span></label>
  116.                                 <input id="post_title" type="text" name="post_title" maxlength="80" />
  117.                             </li>
  118.                             <li id="link-container" style="display:none;">
  119.                                 <label for="post_url">URL <span>don't forget the http://</span></label>
  120.                                 <input id="post_url" type="text" name="post_url" placeholder="http://" />
  121.                             </li>
  122.                             <li id="code-container" style="display:none;">
  123.                                 <label for="post_code">Code</label>
  124.                                 <textarea id="post_code" name="post_code"></textarea>
  125.                             </li>
  126.                             <li>
  127.                                 <div id="discussion-label" style="display:none;"><label for="post_content">Article <span>share your topic</span></label></div>
  128.                                 <div id="code-label" style="display:none;"><label for="post_content">Description <span>what does this code do?</span></label></div>
  129.                                 <div id="link-label" style="display:none;"><label for="post_content">Description <span>where does this link go?</span></label></div>
  130.                                 <textarea id="post_content" name="post_content"></textarea>
  131.                             </li>
  132.                             <li>
  133.                                 <label for="post_tags">Tags <span>separate multiple tags with commas (e.g. tag one, tag two, tag three)</span></label>
  134.                                 <textarea id="post_tags" name="post_tags"></textarea>
  135.                             </li>
  136.                             <li>
  137.                                 <label class="public" for="post_public"><input id="post_public" type="checkbox" name="post_public" value="true" /> Make this post public? <span>( non-members will be able to view this post ) <a title="Find out more" href="<?php bloginfo('url'); ?>/about/#faq">Find out more</a></span></label>
  138.                             </li>
  139.                             <li class="sep clearfix">
  140.                                 <input type="hidden" name="new_post" value="1" />
  141.                                 <input class="submit" type="submit" name="submit" value="Post" />
  142.                                 <a class="cancel" onclick="return confirm('Are you sure you want to cancel your post?');" href="<?php bloginfo('home'); ?>">Cancel</a>
  143.                             </li>
  144.                         </ul>
  145.                     </fieldset>
  146.                     </form>
  147.                    
  148.                 </div>
  149.        
  150.        
  151.             </div>
  152.         </div>
  153.     </div>
  154.  
  155.  
  156. <?php
  157.  
  158.     get_footer();
  159.  
  160. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement