function PostTypes() { screen_icon(); echo '<div class="wrap">'; ?> <script LANGUAGE="JavaScript"> <!-- function confirmSubmit() { var agree=confirm("<?php _e('Are you sure you wish to delete?', THEME_ADMIN_LANG_DOMAIN); ?> "); if (agree) return true ; else return false ; } // --> </script> <h2><?php echo THEME_NAME; _e('Post Types and Taxonomies', THEME_ADMIN_LANG_DOMAIN); ?> </h2> <?php if (isset($_REQUEST["task"])) { $task = $_REQUEST["task"]; } else { $task = false; } switch ($task) { case 'editptype': editpostType(); break; case 'edittax': edittaxType(); break; default: global $wpdb; $table = $wpdb->prefix . 'ultimatum_ptypes'; $table2 = $wpdb->prefix . 'ultimatum_tax'; if ($_POST) { if ($_POST[action] == 'delptype') { // delete post type $delete = "DELETE FROM {$table} WHERE `name`='{$_POST['delptype']}'"; $r = $wpdb->query($delete); $url = curPageURL(); //delete taxonomies of post type $delete = "DELETE FROM {$table2} WHERE `pname`='{$_POST['delptype']}'"; $r = $wpdb->query($delete); } if ($_POST[action] == 'delcptax') { //delete tax type $delete = "DELETE FROM {$table2} WHERE `tname`='{$_POST['delcptax']}'"; $r = $wpdb->query($delete); $url = curPageURL(); } ?> <script language="JavaScript"> parent.location.href='<?php echo $url; ?> '; </script> <?php } flush_rewrite_rules(false); $query = "SELECT * FROM {$table}"; $result = $wpdb->get_results($query, ARRAY_A); echo '<table class="widefat">'; echo '<thead>'; echo '<tr><th width="150">' . __('Custom Post Type', THEME_ADMIN_LANG_DOMAIN) . '</th><th>' . __('Taxonomies', THEME_ADMIN_LANG_DOMAIN) . '</th><th style="text-align:right;" width="150"><a href="admin.php?page=wonder-types&task=editptype" class="button-primary">' . __('Add Post Type', THEME_ADMIN_LANG_DOMAIN) . '</a></th></tr>'; echo '</thead>'; echo '<tbody>'; foreach ($result as $ptypes) { $properties = unserialize($ptypes["properties"]); echo '<tr> <td style="font-size:14px"><a href="admin.php?page=wonder-types&task=editptype&name=' . $ptypes["name"] . '">' . $properties["label"] . '</a></td> <td>' . getTaxes($ptypes["name"]) . '</td> <td align="right"> <p><a href="admin.php?page=wonder-types&task=editptype&name=' . $ptypes["name"] . '" class="button-primary">' . __('Edit Post Type', THEME_ADMIN_LANG_DOMAIN) . '</a><br /><br /><a href="admin.php?page=wonder-types&task=edittax&name=' . $ptypes["name"] . '" class="button-primary">' . __('Add Taxonomy', THEME_ADMIN_LANG_DOMAIN) . '</a></p><form method="post" action=""><input type="hidden" name="action" value="delptype" /><input type="hidden" name="delptype" value="' . $ptypes["name"] . '" /><input type="submit" value="' . __('Delete Post Type', THEME_ADMIN_LANG_DOMAIN) . '" class="button-secondary" onClick="return confirmSubmit()" /></form></td></tr>'; } echo '</tbody>'; echo '</table>'; break; } echo '</div>'; }
function PostTypes(){ echo '<div class="wrap ultwrap">';?> <script LANGUAGE="JavaScript"> <!-- function confirmSubmit() { var agree=confirm("<?php _e('Are you sure you wish to delete?', 'ultimatum');?>"); if (agree) return true ; else return false ; } // --> </script> <?php $defpage='./admin.php?page=wonder-types'; $task=false; if(isset($_GET['task'])) $task = $_GET['task']; ?> <div class="ultadmnavi" style="position:absolute;top:0;width:100%;margin-right:25px;"> <div class="navbar"> <div class="navbar-inner"> <a class="brand" href="<?php echo $defpage;?>"><i class="fa fa-folder-open"></i> <?php _e('Custom Post Types','ultimatum');?></a> <ul class="nav"> <?php if(!$task):?> <li <?php if($task=="edit") echo ' class="active"' ;?>> <a href="<?php echo $defpage.'&task=editptype'; ?>"><?php _e('Create a Post Type','ultimatum');?></a> </li> <?php endif;?> </ul> </div> </div> </div> <p></p> <?php if(isset($_REQUEST["task"])){ $task = $_REQUEST["task"]; } else { $task=false; } switch ($task) { case 'editptype': editpostType(); break; case 'edittax': edittaxType(); break; default: global $wpdb; $table = $wpdb->prefix.ULTIMATUM_PREFIX.'_ptypes'; $table2 = $wpdb->prefix.ULTIMATUM_PREFIX.'_tax'; if($_POST){ if($_POST[action]=='delptype'){ // delete post type $delete = "DELETE FROM $table WHERE `name`='$_POST[delptype]'"; $r = $wpdb->query($delete); $url = curPageURL(); //delete taxonomies of post type $delete = "DELETE FROM $table2 WHERE `pname`='$_POST[delptype]'"; $r = $wpdb->query($delete); } if($_POST[action]=='delcptax'){ //delete tax type $delete = "DELETE FROM $table2 WHERE `tname`='$_POST[delcptax]'"; $r = $wpdb->query($delete); $url = curPageURL(); } ?> <script language="JavaScript"> parent.location.href='<?php echo $url; ?>'; </script> <?php } flush_rewrite_rules(false); $query = "SELECT * FROM $table"; $result = $wpdb->get_results($query,ARRAY_A); echo '<table class="table table-bordered">'; echo '<thead>'; //<th style="text-align:right;" width="150"><a href="admin.php?page=wonder-types&task=editptype" class="button-primary">'.__('Add Post Type', 'ultimatum').'</a></td> echo '<tr class="info"> <td width="150">'.__('Custom Post Type', 'ultimatum').'</td><td>'.__('Taxonomies', 'ultimatum').'</td><td></td> </tr>'; echo '</thead>'; echo '<tbody>'; foreach ($result as $ptypes){ $properties = unserialize($ptypes["properties"]); echo '<tr> <td style="font-size:14px"><a href="admin.php?page=wonder-types&task=editptype&name='.$ptypes["name"].'">'.$properties["label"].'</a></td> <td>'.getTaxes($ptypes["name"]).'</td> <td align="right"> <form method="post" action=""> <input type="hidden" name="action" value="delptype" /><input type="hidden" name="delptype" value="'.$ptypes["name"].'" /> <div class="btn-group templateactions"> <a href="admin.php?page=wonder-types&task=editptype&name='.$ptypes["name"].'" class="btn-primary btn">'.__('Edit Post Type', 'ultimatum').'</a> <a href="admin.php?page=wonder-types&task=edittax&name='.$ptypes["name"].'" class="btn-info btn">'.__('Add Taxonomy', 'ultimatum').'</a> <input type="submit" value="'.__('Delete Post Type', 'ultimatum').'" class="btn-danger btn" style="height:30px;" onClick="return confirmSubmit()" /> </div> </form> </td></tr>'; } echo '</tbody>'; echo '</table>'; break; } echo '</div>'; }