wp_die(); } $capability = self::$args[$page]['capability']; if (!current_user_can($capability)) { wp_die(); } $db_options = get_option($page); $fields = self::$sections[$page][$_POST['section']]['fields']; $type = array_column($fields, 'type', 'id'); foreach ($_POST['data'] as $k => $v) { $class_name = "Sse_" . $type[$k]; $test = call_user_func(array($class_name, 'verify'), $v); $_POST['data'][$k] = $test; } $test = array_merge($db_options, $_POST['data']); update_option($page, $test); $response = array('value' => 1, 'message' => 'Settings updated.'); echo json_encode($response); wp_die(); // this is required to terminate immediately and return a proper response } static function add_admin_menu() { foreach (self::$args as $arg) { $page = add_menu_page($arg["page-title"], $arg["menu-title"], $arg["capability"], $arg["menu-slug"], 'Sse::render_page', $arg["icon"], $arg["position"]); add_action('load-' . $page, array("Sse", 'load_admin_js')); } } } Sse::init();