/** * Saves passed settings * * @global array $wpi_settings * @param array $new_settings */ function SaveSettings($new_settings) { global $wpi_settings; //** Set 'first_time_setup_ran' as 'true' to avoid loading First Time Setup Page in future */ $new_settings['first_time_setup_ran'] = 'true'; $this->options = WPI_Functions::array_merge_recursive_distinct($this->options, $new_settings); //** Copy template files from plugin folder to active theme/template */ if(isset($new_settings['install_use_custom_templates']) && isset($new_settings['use_custom_templates']) && $new_settings['install_use_custom_templates'] == 'yes' && $new_settings['use_custom_templates'] == 'yes') { WPI_Functions::install_templates(); } //** Process Special Settings */ //** Default predefined services */ $this->options['predefined_services'][0]['name'] = __("Web Design Services", WPI); $this->options['predefined_services'][0]['quantity'] = 1; $this->options['predefined_services'][0]['price'] = 30; $this->options['predefined_services'][1]['name'] = __("Web Development Services", WPI); $this->options['predefined_services'][1]['quantity'] = 1; $this->options['predefined_services'][1]['price'] = 30; $this->options['predefined_services'] = ( isset($new_settings['predefined_services']) ? $new_settings['predefined_services'] : $this->options['predefined_services'] ); //** E-Mail Templates */ if(isset($new_settings['notification'])) { $this->options['notification'] = $new_settings['notification']; } //** Process Special Settings */ //** fix checkboxes */ foreach($this->options['billing'] as $key => $value) { if(!isset($new_settings['billing'][$key]['allow'])) unset($this->options['billing'][$key]['allow']); } $checkbox_array = array('increment_invoice_id', 'send_thank_you_email', 'cc_thank_you_email', 'force_https', 'show_recurring_billing', 'send_invoice_creator_email'); foreach($checkbox_array as $checkbox_name) { if(!isset($new_settings[$checkbox_name])) unset($this->options[$checkbox_name]); } $this->CommitUpdates(); //** Update global variable */ $wpi_settings = WPI_Functions::array_merge_recursive_distinct($wpi_settings, $this->options); //** Fix Predefined Services */ $wpi_settings['predefined_services'] = $this->options['predefined_services']; //** Fix E-Mail Templates */ $wpi_settings['notification'] = $this->options['notification']; wpi_gateway_base::sync_billing_objects(); }