function custom_settings() { require 'languages/text_variables.php'; global $wpdb; if (isset($_GET['pid']) && $_GET['pid'] !== "") { $pid = $_GET['pid']; $pay_selection = getDefaultPaymentMethod(); $project = new ID_Project($pid); $product_settings = $project->get_project_settings(); $products = $project->the_project(); if (!empty($product_settings)) { $form = unserialize($product_settings->form_settings); $serializedForm = $product_settings->form_settings; $mc_api = $product_settings->mailchimp_api_key; $mc_list = $product_settings->mailchimp_list_id; $aweber_email = $product_settings->aweber_email; $mailtype = $product_settings->active_mailtype; $paypal_email = $product_settings->paypal_email; $currency_code = $product_settings->currency_code; } else { $mc_api = ''; $mc_list = ''; $aweber_email = ''; $mailtype = ''; $paypal_email = ''; $currency_code = 'USD'; $form = ''; $serializedForm = serialize($form); } } else { $products = ID_Project::get_all_projects(); } if (isset($_POST['btnSubmitProdSettings'])) { if (isset($_POST['mailchimp_api_key'])) { $mc_api = $_POST['mailchimp_api_key']; } if (isset($_POST['mailchimp_list_id'])) { $mc_list = $_POST['mailchimp_list_id']; } if (isset($_POST['aweber_email'])) { $aweber_email = $_POST['aweber_email']; } if (isset($_POST['active_mailtype'])) { $mailtype = $_POST['active_mailtype']; } if (isset($_POST['paypal_email'])) { $paypal_email = $_POST['paypal_email']; } if (isset($_POST['currency_code'])) { $currency_code = $_POST['currency_code']; } if (isset($_POST['ignitiondeck_form'])) { $form = $_POST['ignitiondeck_form']; $serializedForm = serialize($_POST['ignitiondeck_form']); } if (empty($product_settings)) { $sql_insert_product = "INSERT INTO " . $wpdb->prefix . "ign_product_settings (\n\t\t\t\t\t\t\t\t\t\tproduct_id,\n\t\t\t\t\t\t\t\t\t\tmailchimp_api_key,\n\t\t\t\t\t\t\t\t\t\tmailchimp_list_id,\n\t\t\t\t\t\t\t\t\t\taweber_email,\n\t\t\t\t\t\t\t\t\t\tactive_mailtype,\n\t\t\t\t\t\t\t\t\t\tform_settings,\n\t\t\t\t\t\t\t\t\t\tpaypal_email,\n\t\t\t\t\t\t\t\t\t\tcurrency_code\n\t\t\t\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t\t\t\t'" . $_GET['pid'] . "',\n\t\t\t\t\t\t\t\t\t\t'" . $mc_api . "',\n\t\t\t\t\t\t\t\t\t\t'" . $mc_list . "',\n\t\t\t\t\t\t\t\t\t\t'" . $aweber_email . "',\n\t\t\t\t\t\t\t\t\t\t'" . $mailtype . "',\n\t\t\t\t\t\t\t\t\t\t'" . $serializedForm . "',\n\t\t\t\t\t\t\t\t\t\t'" . $paypal_email . "',\n\t\t\t\t\t\t\t\t\t\t'" . $currency_code . "'\n\t\t\t\t\t\t\t\t\t)"; $wpdb->query($sql_insert_product); $message = '<div class="updated fade below-h2" id="message" class="updated"><p>' . $tr_Save_Settings . '</p></div>'; } else { $sql_update_product = "UPDATE " . $wpdb->prefix . "ign_product_settings SET\n\t\t\t\t\t\t\t\t\tmailchimp_api_key = '" . $mc_api . "',\n\t\t\t\t\t\t\t\t\tmailchimp_list_id = '" . $mc_list . "',\n\t\t\t\t\t\t\t\t\taweber_email = '" . $aweber_email . "',\n\t\t\t\t\t\t\t\t\tactive_mailtype = '" . $mailtype . "',\n\t\t\t\t\t\t\t\t\tform_settings = '" . $serializedForm . "',\n\t\t\t\t\t\t\t\t\tpaypal_email = '" . $paypal_email . "',\n\t\t\t\t\t\t\t\t\tcurrency_code = '" . $currency_code . "'\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tWHERE product_id = '" . $_GET['pid'] . "'\n\t\t\t\t\t\t\t\t\t"; $wpdb->query($sql_update_product); $message = '<div class="updated fade below-h2" id="message" class="updated"><p>' . $tr_Settings_updated . '</p></div>'; } } else { if (isset($_POST['btnClearProdSettings']) && $_POST['btnClearProdSettings'] != "") { $pid = $_GET['pid']; $project = new ID_Project($pid); $clear = $project->clear_project_settings(); echo '<script>window.location="";</script>'; } else { if (isset($_POST['btnClearAllSettings']) && $_POST['btnClearAllSettings'] != "") { $sql = "DELETE FROM " . $wpdb->prefix . "ign_product_settings"; $clear_all_product_settings = $wpdb->query($sql); } } } echo '<div class="wrap"> ' . admin_menu_html(); include_once 'templates/admin/_customSettings.php'; echo '</div>'; }