public function auto_extract($project_path) { // First let's ensure we have decoded the project path for use later. $project_path = urldecode($project_path); // Get the URL to the project for use later. $url = gp_url_project($project_path); // Create a project class to use to get the project object. $project_class = new GP_Project(); // Get the project object from the project path that was passed in. $project_obj = $project_class->by_path($project_path); if (GP::$permission->user_can(wp_get_current_user(), 'write', 'project', $project->id)) { // Get the project settings. $project_settings = (array) get_option('gp_auto_extract', array()); // Since we're running on the front end we need to load the download_url() function from the wp-admin/includes directory. include ABSPATH . 'wp-admin/includes/file.php'; // Extract the strings, the third parameter disables HTML formating of the returned messages as GP doesn't need them. $message = $this->extract_project($project_obj, $project_settings, false); } else { $message = 'You do not have rights to auto extract originals!'; } gp_notice_set($message); // Redirect back to the project home. wp_redirect($url); }
function set_notices_and_errors() { if ($this->fake_request) { return; } foreach ($this->notices as $notice) { gp_notice_set($notice); } $this->notices = array(); foreach ($this->errors as $error) { gp_notice_set($error, 'error'); } $this->errors = array(); }
function after_request() { // we can't unregister a shutdown function // this check prevents this method from being run twice if (!$this->request_running) { return; } // set errors and notices if (!headers_sent()) { foreach ($this->notices as $notice) { gp_notice_set($notice); } foreach ($this->errors as $error) { gp_notice_set($error, 'error'); } } do_action('after_request', $this->class_name, $this->last_method_called); }