<?php

defined('WP_PLUGIN_URL') or die('Restricted access');
if (!current_user_can('publish_posts')) {
    wp_die(__('You do not have sufficient permissions to access this page.'));
}
$object = new WordPress_Plugin_Model(null, null, $_GET['action'], $_GET['id']);
?>
<div class="wrap wprmm">
  <div id="icon-tools" class="icon32"></div><h2 class="left">Edit <?php 
echo $object->name;
?>
</h2>
  <div class="clear"></div>
  <hr />

  <?php 
#wprmm_get_help(array('main'=>true));
?>

  <form method="post" action="<?php 
echo $object->form_post_url;
?>
">
    <table class="form-table">    
      <tbody>

        <?php 
foreach ($object->structure as $field) {
    ?>
          <?php 
<?php

defined('WP_PLUGIN_URL') or die('Restricted access');
#print_r($_POST);
if (isset($this)) {
    /* New Object POST'd, Save record and redirect to edit */
    if ($_POST[$this->class_name]['action'] == "new" && !empty($_POST[$this->class_name]['submit'])) {
        $object = new WordPress_Plugin_Model(null, null, 'create', null, $_POST[$this->class_name]);
    }
    /* Delete Record from GET id and redirect to index */
    if ($_GET['action'] == "delete") {
        $object = new WordPress_Plugin_Model(null, null, 'delete', $_GET['id']);
    }
}
$objects = new WordPress_Plugin_Model(null, null, 'dispatch');
#var_dump($objects);
$objects->load_action();