function SavePostType() { global $wpdb; if (!empty($_POST)) { //Sanitize data $data = array(); foreach ($_POST as $key => $value) { $key = esc_html($key); $value = esc_html($value); $data[$key] = $value; } $name = esc_html($data['post_type_name']); $desc = esc_html($data['description']); unset($data['post_type_name']); unset($data['description']); $settings = json_encode($data); //Saving the new post type $wpdb->insert(MF_TABLE_POSTTYPES_TAXONOMIES, array('type' => 'posttype', 'name' => $name, 'description' => $desc, 'settings' => $settings), array('%s', '%s', '%s', '%s')); print_r($_POST); } }
/** * Determine which action will be executed * */ function Dispacher() { if (empty($_GET['action'])) { $action = "manage"; } else { $action = $_GET['action']; } $action = esc_attr($action); switch ($action) { case "manage": MF_PostTypePages::ManagePostType(); break; case "add": MF_PostTypePages::AddPostType(); break; case "save": MF_PostTypePages::SavePostType(); } }