HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wpemobiq/wp-content/plugins/code-snippets/php/export/class-export-attachment.php
<?php

namespace Code_Snippets;

/**
 * Handles exporting snippets from the site to a downloadable file over HTTP.
 *
 * @package Code_Snippets
 */
class Export_Attachment extends Export {

	/**
	 * Set up the current page to act like a downloadable file instead of being shown in the browser
	 *
	 * @param string $language  File format. Used for file extension.
	 * @param string $mime_type File MIME type. Used for Content-Type header.
	 */
	private function do_headers( string $language, string $mime_type = 'text/plain' ) {
		header( 'Content-Disposition: attachment; filename=' . sanitize_file_name( $this->build_filename( $language ) ) );
		header( sprintf( 'Content-Type: %s; charset=%s', sanitize_mime_type( $mime_type ), get_bloginfo( 'charset' ) ) );
	}

	/**
	 * Export snippets in JSON format as a downloadable file.
	 */
	public function download_snippets_json() {
		$this->do_headers( 'json', 'application/json' );
		// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
		echo wp_json_encode(
			$this->create_export_object(),
			apply_filters( 'code_snippets/export/json_encode_options', 0 )
		);
		exit;
	}

	/**
	 * Export snippets in their code file format.
	 */
	public function download_snippets_code() {
		$lang = $this->snippets_list[0]->lang;

		$mime_types = [
			'php'  => 'text/php',
			'css'  => 'text/css',
			'js'   => 'text/javascript',
			'json' => 'application/json',
		];

		$this->do_headers( $lang, $mime_types[ $lang ] ?? 'text/plain' );

		// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
		echo $this->export_snippets_code( $this->snippets_list[0]->type );
		exit;
	}
}