/** * Saves global settings */ public static function save_settings() { $lp_global_settings = Landing_Pages_Settings::get_settings(); if (!isset($_POST['nature'])) { return; } foreach ($lp_global_settings as $key => $data) { $tab_settings = $lp_global_settings[$key]['settings']; /* loop through fields and save the data */ foreach ($tab_settings as $field) { $field['id'] = $key . "-" . $field['id']; if (array_key_exists('option_name', $field) && $field['option_name']) { $field['id'] = $field['option_name']; } $field['old_value'] = get_option($field['id']); isset($_POST[$field['id']]) ? $field['new_value'] = $_POST[$field['id']] : ($field['new_value'] = null); if ($field['new_value'] !== null && $field['new_value'] !== $field['old_value']) { update_option($field['id'], $field['new_value']); if ($field['id'] == 'main-landing-page-permalink-prefix') { /*echo "here"; */ global $wp_rewrite; $wp_rewrite->flush_rules(); } if ($field['type'] == 'license-key') { $master_key = get_option('inboundnow_master_license_key'); if ($master_key) { $field['new_value'] = $master_key; } $api_params = array('edd_action' => 'activate_license', 'license' => $field['new_value'], 'item_name' => $field['slug'], 'cache_bust' => substr(md5(rand()), 0, 7)); $response = wp_remote_get(add_query_arg($api_params, LANDINGPAGES_STORE_URL), array('timeout' => 30, 'sslverify' => false)); if (is_wp_error($response)) { break; } $license_data = json_decode(wp_remote_retrieve_body($response)); $license_status = update_option('lp_license_status-' . $field['slug'], $license_data->license); } } else { if ($field['new_value'] == null) { if ($field['type'] == 'license-key') { $master_key = get_option('inboundnow_master_license_key'); if ($master_key) { $bool = update_option($field['id'], $master_key); $license_status = update_option('lp_license_status-' . $field['slug'], ''); } else { update_option($field['id'], ''); $license_status = update_option('lp_license_status-' . $field['slug'], ''); } } } } do_action('lp_save_global_settings', $field); } } }
/** * Saves global settings */ public static function save_settings() { $lp_global_settings = Landing_Pages_Settings::get_settings(); if (!isset($_POST['nature'])) { return; } foreach ($lp_global_settings as $key => $data) { $tab_settings = $lp_global_settings[$key]['settings']; /* loop through fields and save the data */ foreach ($tab_settings as $field) { $field['id'] = $key . "-" . $field['id']; if (array_key_exists('option_name', $field) && $field['option_name']) { $field['id'] = $field['option_name']; } if ($field['id'] == 'main-landing-page-permalink-prefix') { /*echo "here"; */ global $wp_rewrite; $wp_rewrite->flush_rules(); } if ($field['type'] == 'inboundnow-license-key') { /* error_log(print_r($field, true)); */ $slug = isset($field['remote_download_slug']) ? $field['remote_download_slug'] : $field['slug']; $api_params = array('edd_action' => 'activate_license', 'license' => $_POST['inboundnow_master_license_key'], 'item_name' => $slug); /* error_log(print_r($api_params, true)); */ /* Call the edd API */ $response = wp_remote_get(add_query_arg($api_params, WPL_STORE_URL), array('timeout' => 30, 'sslverify' => false)); /* error_log(print_r($response, true)); */ /* make sure the response came back okay */ if (is_wp_error($response)) { break; } /* decode the license data */ $license_data = json_decode(wp_remote_retrieve_body($response)); /* error_log(print_r($license_data, true)); */ /* $license_data->license will be either "active" or "inactive" */ update_option('lp_license_status-' . $field['slug'], $license_data->license); } else { if (isset($_POST[$field['id']])) { update_option($field['id'], $_POST[$field['id']]); } } do_action('lp_save_global_settings', $field); } } }