/** * Saves a config * * @uses "wp_ajax_epoch_save_config" hook * * @since 0.0.1 */ public function save_config() { if (empty($_POST['epoch-setup']) || !wp_verify_nonce($_POST['epoch-setup'], 'epoch')) { if (empty($_POST['config'])) { return; } } if (!empty($_POST['epoch-setup']) && empty($_POST['config'])) { $config = stripslashes_deep($_POST['config']); options::update($config); wp_redirect('?page=epoch&updated=true'); exit; } if (!empty($_POST['config'])) { $config = json_decode(stripslashes_deep($_POST['config']), true); if (wp_verify_nonce($config['epoch-setup'], 'epoch')) { options::update($config); wp_send_json_success($config); } } // nope wp_send_json_error($config); }
/** * Create a new item * * @uses "wp_ajax_frmwks_create_formworks" action * * @since 0.0.1 */ public function create_new_formworks() { $can = options::can(); if (!$can) { status_header(500); wp_die(__('Access denied', 'formworks')); } if (!empty($_POST['import'])) { $config = json_decode(stripslashes_deep($_POST['import']), true); if (empty($config['name']) || empty($config['slug'])) { wp_send_json_error($_POST); } $id = null; if (!empty($config['id'])) { $id = $config['id']; } options::create($config['name'], $config['slug'], $id); options::update($config); wp_send_json_success($config); } $new = options::create($_POST['name'], $_POST['slug'], $_POST['form'], $_POST['view_type']); if (is_array($new)) { wp_send_json_success($new); } else { wp_send_json_error($_POST); } }
<?php require_once '../connect.php'; require_once '../Classes/option.class.php'; options::update(); header('Location: ../db.php');