/** * Generic function to inform SC about sections on the website not working properly * **/ function throw_service_error($service, $message = '') { throw_error('500', 'Error connecting to API server'); $fieds['Hora'] = current_time('mysql'); if ($message) { $fieds['Missatge d\'error'] = $message; } sendEmailForm('*****@*****.**', $service, 'El servei «' . $service . '» no està funcionant correctament', $fields); }
/** * Creates a new post of the type 'aparell' using the data sent from the form ($_POST) * * @return json response */ function sc_send_aparell() { $return = array(); if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], $_POST["action"])) { $return['status'] = 0; } else { check_is_ajax_call(); $nom = sanitize_text_field($_POST["nom"]); $tipus_aparell = sanitize_text_field($_POST["tipus_aparell"]); $fabricant = sanitize_text_field($_POST["fabricant"]); $sistema_operatiu = sanitize_text_field($_POST["sistema_operatiu"]); $versio = sanitize_text_field($_POST["versio"]); $traduccio_catala = sanitize_text_field($_POST["traduccio_catala"]); $correccio_catala = sanitize_text_field($_POST["correccio_catala"]); $slug = sanitize_title_with_dashes($nom); // comentari no s'utilitza $comentari = stripslashes(sanitize_text_field($_POST["comentari"])); $terms = array('tipus_aparell' => array($tipus_aparell), 'so_aparell' => array($sistema_operatiu)); $metadata = array('versio' => $versio, 'fabricant' => $fabricant, 'conf_cat' => $traduccio_catala, 'correccio_cat' => $correccio_catala); $return = sc_add_draft_content('aparell', $nom, '', $slug, $terms, $metadata); if ($return['status'] == 1) { $to_email = "*****@*****.**"; $nom_from = "Aparells de Softcatalà"; $assumpte = "[Aparells] Aparell enviat per formulari"; $fields = array("Nom de l'aparell" => $nom, "Comentari" => $comentari, "URL Dashboard" => admin_url("post.php?post=" . $return['post_id'] . "&action=edit")); sendEmailForm($to_email, $nom_from, $assumpte, $fields); } } $response = json_encode($return); die($response); }