AdminPageFrameworkLoader_AdminPage_Tool_Minifier_Minifier::validate PHP Метод

validate() публичный Метод

Validates the submitted form data.
С версии: 3.4.6
С версии: 3.5.4 Moved from `AdminPageFrameworkLoader_AdminPage_Tool_Minifier`.
public validate ( $aInput, $aOldInput, $oAdminPage, $aSubmitInfo )
    public function validate($aInput, $aOldInput, $oAdminPage, $aSubmitInfo)
    {
        $_bVerified = true;
        $_aErrors = array();
        // Sanitize the file name.
        $aInput['minified_script_name'] = $oAdminPage->oUtil->sanitizeFileName($aInput['minified_script_name'], '-');
        // the class prefix must not contain white spaces and some other characters not supported in PHP class names.
        $aInput['class_prefix'] = isset($aInput['class_prefix']) ? trim($aInput['class_prefix']) : '';
        preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $aInput['class_prefix'], $_aMatches);
        if ($aInput['class_prefix'] && empty($_aMatches)) {
            // $variable[ 'sectioni_id' ]['field_id']
            $_aErrors['class_prefix'] = __('The prefix must consist of alphanumeric with underscores.', 'admin-page-framework-loader');
            $_bVerified = false;
        }
        /* 4. An invalid value is found. */
        if (!$_bVerified) {
            /* 4-1. Set the error array for the input fields. */
            $oAdminPage->setFieldErrors($_aErrors);
            $oAdminPage->setSettingNotice(__('There was something wrong with your input.', 'admin-page-framework-loader'));
            return $aOldInput;
        }
        return $aInput;
    }