Page Creator backend

Need to create pages based on a site map?


function page_creator_menu() {
   add_menu_page('page creator', 'page creator', 'manage_options', 'page creator','top_level_page_creator');
}
 
function top_level_page_creator() { //844AM
 
 
	if(isset($_POST['has_submitted_create_pages'])) { //117PM
	
	    $pages_parent   = $_POST['pages_parent'];
		$all_page_names = $_POST['page_name']; 
		$all_page_slugs = $_POST['page_slug'];
	     
	    $count = 0; 
	
	    foreach ($all_page_names as $key => $page_name) { //2:45PM
	      
	        if (!empty($all_page_names[$count])) { //253PM
	        
				// Create post object
				$my_post = array(
				  'post_type'     => 'page',
				  'post_title'    => $all_page_names[$count],
				  'post_status'   => 'publish',
				  'post_author'   => 1,
				  'post_parent'   => $pages_parent,
				  'post_name'     => $all_page_slugs[$count],
				);
				
				// Insert the post into the database				
				$insert_status = wp_insert_post( $my_post );
				
				
		        echo "<div>$insert_status PAGE NAME->".$all_page_names[$count]." </div>";

	        } //253PM
	    
	        $count++;
	    } //2:45PM
	
	
	 
	 
	 
	}//117PM
 
 

 
?>
 
<style>
        
page_creator_wrap { display: block;}
.text_input { width: 250px;margin-bottom: 15px;}
</style>
 
<h1>page creator</h1>               
         
        
        <form class="page_creator" method="post" enctype="multipart/form-data">
       
                 
                <label>pages parent</label> 
                <input type="text" name="pages_parent" class="text_input" value=""/>                 
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <page_creator_wrap>
                
	                <single_creaton_wrap>                  
	                <label>page name</label> 
	                <input type="text" name="page_name[]" class="text_input" value=""/> 
	 
	                <label>page slug</label> 
	                <input type="text" name="page_slug[]" class="text_input" value=""/>  
	                </single_creaton_wrap>
                
                </page_creator_wrap>
                
                <input type="submit" class="create_pages_submit" value="Submit" />       
                <input type="hidden" name="has_submitted_create_pages" id="has_submitted_create_pages" value="true" /> 
        </form>
        
        


<?      
        
        
         
} //844AM
 
add_action('admin_menu', 'page_creator_menu');

Comments