/** * Called on save form. Only POST allowed. */ public function save_post_form() { //Allowed Pages if (!in_array($_POST['page'], array('backwpupeditjob', 'backwpupinformation', 'backwpupsettings'))) { wp_die(__('Cheating, huh?', 'backwpup')); } //nonce check check_admin_referer($_POST['page'] . '_page'); if (!current_user_can('backwpup')) { wp_die(__('Cheating, huh?', 'backwpup')); } //build query for redirect if (!isset($_POST['anchor'])) { $_POST['anchor'] = NULL; } $query_args = array(); if (isset($_POST['page'])) { $query_args['page'] = $_POST['page']; } if (isset($_POST['tab'])) { $query_args['tab'] = $_POST['tab']; } if (isset($_POST['tab']) && isset($_POST['nexttab']) && $_POST['tab'] != $_POST['nexttab']) { $query_args['tab'] = $_POST['nexttab']; } $jobid = NULL; if (isset($_POST['jobid'])) { $jobid = (int) $_POST['jobid']; $query_args['jobid'] = $jobid; } //Call method to save data if ($_POST['page'] == 'backwpupeditjob') { BackWPup_Page_Editjob::save_post_form($_POST['tab'], $jobid); } elseif ($_POST['page'] == 'backwpupsettings') { BackWPup_Page_Settings::save_post_form(); } //Back to topic wp_safe_redirect(add_query_arg($query_args, network_admin_url('admin.php')) . $_POST['anchor']); exit; }
protected function update_settings() { $settings = $_POST['settings']; if (!is_array($settings) || !isset($settings['value'])) { return array('error' => __('Missing array settings', $this->plugin_translate)); } if (!class_exists('BackWPup')) { return array('error' => __('Install BackWPup on child website', $this->plugin_translate)); } if (isset($settings['value']['is_premium']) && $settings['value']['is_premium'] == 1 && $this->is_backwpup_pro == false) { return array('error' => __('You try to use pro version settings in non pro plugin version. Please install pro version on child and try again.', $this->plugin_translate)); } foreach ($settings['value'] as $key => $val) { $_POST[$key] = $val; } update_site_option('backwpup_messages', array()); $backwpup = new BackWPup_Page_Settings(); $backwpup->save_post_form(); if (class_exists('BackWPup_Pro')) { $pro_settings = BackWPup_Pro_Settings_APIKeys::get_instance(); $pro_settings->save_form(); } $return = $this->check_backwpup_messages(); if (isset($return['error'])) { return array('error' => __('Cannot save settings: ' . $return['error'], $this->plugin_translate)); } $exclusions = array('is_premium', 'dropboxappsecret', 'dropboxsandboxappsecret', 'sugarsyncsecret', 'googleclientsecret', 'override', 'httpauthpassword'); $changes_array = array(); foreach ($settings['value'] as $key => $val) { $temp_value = get_site_option('backwpup_cfg_' . $key, ''); if (!in_array($key, $exclusions) && strcmp($temp_value, $val) != 0) { $changes_array[$key] = $temp_value; } } return array('success' => 1, 'changes' => $changes_array, 'message' => $return['message']); }