private function importOptions($arrInput, $strPageSlug, $strTabSlug) { $oImport = new FetchTweets_AdminPageFramework_ImportOptions($_FILES['__import'], $_POST['__import']); // Check if there is an upload error. if ($oImport->getError() > 0) { add_settings_error($this->oProps->strOptionKey, $strPageSlug, $this->oMsg->___('import_error'), 'error'); return $arrInput; // do not change the framework's options. } // Check the uploaded file type. if (!in_array($oImport->getType(), array('text/plain', 'application/octet-stream'))) { // .json file is dealt as binary file. add_settings_error($this->oProps->strOptionKey, $strPageSlug, $this->oMsg->___('uploaded_file_type_not_supported'), 'error'); return $arrInput; // do not change the framework's options. } // Retrieve the importing data. $vData = $oImport->getImportData(); if ($vData === false) { add_settings_error($this->oProps->strOptionKey, $strPageSlug, $this->oMsg->___('could_not_load_importing_data'), 'error'); return $arrInput; // do not change the framework's options. } // Apply filters to the data format type. $strFormatType = $this->oUtil->addAndApplyFilters($this, $this->oUtil->getFilterArrayByPrefix('import_format_', $this->oProps->strClassName, $strPageSlug, $strTabSlug), $oImport->getFormatType(), $oImport->getFieldID()); // import_format_{$strPageSlug}_{$strTabSlug}, import_format_{$strPageSlug}, import_format_{$strClassName} // Format it. $oImport->formatImportData($vData, $strFormatType); // it is passed as reference. // Apply filters to the importing data. $vData = $this->oUtil->addAndApplyFilters($this, $this->oUtil->getFilterArrayByPrefix('import_', $this->oProps->strClassName, $strPageSlug, $strTabSlug), $vData, $oImport->getFieldID()); // Set the admin notice. add_settings_error($this->oProps->strOptionKey, $strPageSlug, $this->oMsg->___('imported_data'), 'updated'); // If a custom option key is set, // Apply filters to the importing option key. $strImportOptionKey = $this->oUtil->addAndApplyFilters($this, $this->oUtil->getFilterArrayByPrefix('import_option_key_', $this->oProps->strClassName, $strPageSlug, $strTabSlug), $oImport->getImportOptionKey(), $oImport->getFieldID()); // import_option_key_{$strPageSlug}_{$strTabSlug}, import_option_key_{$strPageSlug}, import_option_key_{$strClassName} if ($strImportOptionKey != $this->oProps->strOptionKey) { update_option($strImportOptionKey, $vData); return $arrInput; // do not change the framework's options. } return $vData; }