/** * Validates submitted form data. */ public function validate($aInput, $aOriginal, $oFactory) { $_oOption = AmazonAutoLinks_Option::getInstance(); $_oUtil = new AmazonAutoLinks_WPUtility(); add_filter('safe_style_css', array($this, 'replyToAddAllowedInlineCSSProperties')); $_aAllowedHTMLTags = $_oUtil->convertStringToArray($_oOption->get('form_options', 'allowed_html_tags'), ','); $aInput['item_format'] = $_oUtil->escapeKSESFilter($aInput['item_format'], $_aAllowedHTMLTags); $aInput['image_format'] = $_oUtil->escapeKSESFilter($aInput['image_format'], $_aAllowedHTMLTags); $aInput['title_format'] = $_oUtil->escapeKSESFilter($aInput['title_format'], $_aAllowedHTMLTags); remove_filter('safe_style_css', array($this, 'replyToAddAllowedInlineCSSProperties')); // Schedule pre-fetch for the unit if the options have been changed. if ($aInput !== $aOriginal) { AmazonAutoLinks_Event_Scheduler::prefetch(AmazonAutoLinks_PluginUtility::getCurrentPostID()); } return $aInput; }
/** * Validates submitted form data. */ public function validate($aInput, $aOriginal, $oFactory) { // Formats the options $_oUnitOption = new AmazonAutoLinks_UnitOption_search(null, $aInput); $_aFormatted = $_oUnitOption->get(); // Drop unsent keys. foreach ($_aFormatted as $_sKey => $_mValue) { if (!array_key_exists($_sKey, $aInput)) { unset($_aFormatted[$_sKey]); } } // Schedule pre-fetch for the unit if the options have been changed. if ($aInput !== $aOriginal) { AmazonAutoLinks_Event_Scheduler::prefetch(AmazonAutoLinks_PluginUtility::getCurrentPostID()); } return $_aFormatted + $aInput; }
/** * Validates submitted form data. */ public function validate($aInput, $aOriginal, $oFactory) { $_aErrors = array(); $_bVerified = true; // Formats the options $_oUnitOption = new AmazonAutoLinks_UnitOption_url(null, $aInput); $_aFormatted = $_oUnitOption->get(); // Check if a url iset. $aInput['urls'] = $this->oUtil->getAsArray($aInput['urls']); if (empty($aInput['urls'])) { $_aErrors['urls'] = __('Please set a url.', 'amazon-auto-links'); $_bVerified = false; } // An invalid value is found. if (!$_bVerified) { // Set the error array for the input fields. $oFactory->setFieldErrors($_aErrors); $oFactory->setSettingNotice(__('There was an error in your input.', 'amazon-auto-links')); return $aInput; } // Sanitize foreach ($aInput['urls'] as $_iIndex => $_sURL) { $aInput['urls'][$_iIndex] = trim($_sURL); } // Drop unsent keys. foreach ($_aFormatted as $_sKey => $_mValue) { if (!array_key_exists($_sKey, $aInput)) { unset($_aFormatted[$_sKey]); } } // Schedule pre-fetch for the unit if the options have been changed. if ($aInput !== $aOriginal) { AmazonAutoLinks_Event_Scheduler::prefetch(AmazonAutoLinks_PluginUtility::getCurrentPostID()); } return $_aFormatted + $aInput; }