Exemple #1
0
 /**
  * Validates settings for WordPress to save.
  *
  * @param array $input Input data to validate.
  *
  * @return array Sanitized output for saving.
  */
 public function validate($input)
 {
     try {
         $currentTab = $this->getCurrentTab();
         /** @var TabInterface $tab */
         $tab = $this->tabs[$currentTab];
         $this->options->update($currentTab, $tab->validate($input));
     } catch (Admin\Settings\ValidationException $e) {
         $this->messages->addError($e->getMessage(), true);
         $this->wp->wpSafeRedirect(admin_url(sprintf('admin.php?page=%s&tab=%s', self::NAME, $tab->getSlug())));
         exit;
     }
     return $this->options->getAll();
 }