private static function delWidOptions()
 {
     erpPaths::requireOnce(erpPaths::$erpWidOpts);
     $wOpts = new erpWidOpts();
     delete_option($wOpts->getOptionsArrayName());
 }
 /**
  * Sanitize widget form values as they are saved.
  *
  * @see WP_Widget::update()
  *
  * @param array $new_instance
  *        	Values just sent to be saved.
  * @param array $old_instance
  *        	Previously saved values from database.
  * @return array Updated safe values to be saved.
  * @since 2.0.0
  * @author Panagiotis Vagenas <*****@*****.**>
  */
 public function update($new_instance, $old_instance)
 {
     /* #? Verify nonce */
     if (!isset($_POST['erp_meta_box_nonce']) || !wp_verify_nonce($_POST['erp_meta_box_nonce'], 'erp_meta_box_nonce')) {
         return;
     }
     erpPaths::requireOnce(erpPaths::$erpWidOpts);
     // get an instance to validate options
     $widOpts = new erpWidOpts($old_instance);
     // validate wid options
     $widOptsValidated = $widOpts->saveOptions($new_instance, $old_instance);
     // validate template options
     if (isset($new_instance['dsplLayout'])) {
         erpPaths::requireOnce(erpPaths::$VPluginThemeFactory);
         VPluginThemeFactory::registerThemeInPathRecursive(erpPaths::getAbsPath(erpPaths::$widgetThemesFolder), $new_instance['dsplLayout']);
         $theme = VPluginThemeFactory::getThemeByName($new_instance['dsplLayout']);
         if ($theme) {
             $themeValidated = $theme->saveSettings($new_instance);
             foreach ($theme->getDefOptions() as $key => $value) {
                 unset($new_instance[$key]);
             }
         } else {
             $message = new WP_Error_Notice('Theme ' . $new_instance['dsplLayout'] . ' not found. Theme options discarded');
             WP_Admin_Notices::getInstance()->addNotice($message);
         }
     }
     // save updated options
     return $widOptsValidated + $themeValidated;
 }