/** * get_file_contents * @param string $full_file_path * @return string */ public static function get_file_contents($full_file_path = '') { $full_file_path = EEH_File::standardise_directory_separators($full_file_path); if (EEH_File::verify_filepath_and_permissions($full_file_path, EEH_File::get_filename_from_filepath($full_file_path), EEH_File::get_file_extension($full_file_path))) { // load WP_Filesystem and set file permissions $wp_filesystem = EEH_File::_get_wp_filesystem(); return $wp_filesystem->get_contents($full_file_path); } return ''; }
public function test_get_filename_from_filepath() { $file_path = '/var/whatever/thing.txt'; $this->assertEquals('thing.txt', EEH_File::get_filename_from_filepath($file_path)); }
/** * Loads a page for running a batch job that creates and downloads a file, * and then sends the user back to wherever they were before */ protected function batch_file_create() { //creates a job based on the request variable $job_handler_classname = str_replace('\\\\', '\\', $this->_req_data['job_handler']); $request_data = array_diff_key($this->_req_data, array_flip(array('action', 'page'))); $batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor(); //eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' $job_response = $batch_runner->create_job($job_handler_classname, $request_data); wp_localize_script('support_batch_file_runner', 'ee_job_response', $job_response->to_array()); wp_localize_script('support_batch_file_runner', 'ee_job_i18n', array('download_and_redirecting' => sprintf(__('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'), '<a href="' . $this->_req_data['redirect_url'] . '">', '</a>'), 'redirect_url' => $this->_req_data['redirect_url'])); echo EEH_Template::locate_template(EE_SUPPORT_ADMIN . 'templates' . DS . 'admin_batch_file_runner.template.html', array('filename' => EEH_File::get_filename_from_filepath($job_response->job_parameters()->extra_datum('filepath')))); }