/** * Save edit_login_builder * * Add a new builder to the DB and also update builder * * @param $operation string add/edit * @param $id int builder id */ public function save_add_edit_login_builder($operation, $id = '') { if (isset($_POST['add_login']) || isset($_POST['edit_login'])) { $title = esc_attr($_POST['lfb_title']); $structure = stripslashes($_POST['lfb_structure']); $css = stripslashes($_POST['lfb_css']); // catch and save form generated errors in property @login_builder_errors if (empty($_POST['lfb_title'])) { $this->login_builder_errors = 'Title is empty'; } elseif (empty($_POST['lfb_structure'])) { $this->login_builder_errors = 'Login Design is missing'; } if (isset($this->login_builder_errors)) { return; } if (isset($_POST['edit_login']) && check_admin_referer('edit_login_builder', '_wpnonce') && $operation == 'edit') { // update login in db PROFILEPRESS_sql::sql_update_login_builder($id, $title, $structure, $css, date('Y-m-d')); wp_redirect(add_query_arg('login-edited', 'true')); exit; } elseif (isset($_POST['add_login']) && check_admin_referer('add_login_builder', '_wpnonce') && $operation == 'add') { // insert the login to db $added_login_id = PROFILEPRESS_sql::sql_insert_login_builder($title, $structure, $css, date('Y-m-d')); wp_redirect(sprintf('?page=%s&action=%s&login=%s&_wpnonce=%s&login-added=true', LOGIN_BUILDER_SETTINGS_PAGE_SLUG, 'edit', absint($added_login_id), wp_create_nonce('pp_edit_login'))); exit; } } }