Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux pod-100823:apache2_74:v0.5.7 5.4.0-1138-gcp #147~18.04.1-Ubuntu SMP Mon Oct 7 21:46:26 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33.7
Disable Function : apache_child_terminate,apache_get_modules,apache_get_version,apache_getenv,apache_note,apache_setenv,disk_free_space,disk_total_space,diskfreespace,dl,exec,fastcgi_finish_request,link,opcache_compile_file,opcache_get_configuration,opcache_invalidate,opcache_is_script_cached,opcache_reset,passthru,pclose,pcntl_exec,popen,posix_getpid,posix_getppid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,realpath_cache_get,shell_exec,show_source,symlink,system
Directory :  /nas/content/live/attorneyexperi/wp-content/plugins/diva/src/Cli/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /nas/content/live/attorneyexperi/wp-content/plugins/diva/src/Cli/OptimizerCommand.php
<?php
/**
 * Class OptimizerCommand.
 *
 * Commands that deal with the AMP optimizer.
 *
 * @package AmpProject\AmpWP
 */

namespace AmpProject\AmpWP\Cli;

use AmpProject\AmpWP\Infrastructure\CliCommand;
use AmpProject\AmpWP\Infrastructure\Service;
use AmpProject\AmpWP\Optimizer\OptimizerService;
use AmpProject\Optimizer\Error;
use AmpProject\Optimizer\ErrorCollection;
use WP_CLI;

/**
 * Commands that deal with the AMP optimizer. (EXPERIMENTAL)
 *
 * Note: The Optimizer CLI commands are to be considered experimental, as
 * the output they produce is currently not guaranteed to be consistent
 * with the corresponding output from the web server code path.
 *
 * @since 2.1.0
 * @internal
 */
final class OptimizerCommand implements Service, CliCommand {

	/**
	 * Optimizer service instance to use.
	 *
	 * @var OptimizerService
	 */
	private $optimizer_service;

	/**
	 * Get the name under which to register the CLI command.
	 *
	 * @return string The name under which to register the CLI command.
	 */
	public static function get_command_name() {
		return 'amp optimizer';
	}

	/**
	 * OptimizerCommand constructor.
	 *
	 * @param OptimizerService $optimizer_service Optimizer service instance to use.
	 */
	public function __construct( OptimizerService $optimizer_service ) {
		$this->optimizer_service = $optimizer_service;
	}

	/**
	 * Run a file through the AMP Optimizer. (EXPERIMENTAL)
	 *
	 * Note: The Optimizer CLI commands are to be considered experimental, as
	 * the output they produce is currently not guaranteed to be consistent
	 * with the corresponding output from the web server code path.
	 *
	 * ## OPTIONS
	 *
	 * [<file>]
	 * : Input file to run through the AMP Optimizer. Omit or use '-' to read from STDIN.
	 *
	 * ## EXAMPLES
	 *
	 * # Test <amp-img> SSR transformations and store them in a new file named 'output.html'.
	 * $ echo '<amp-img src="image.jpg" width="500" height="500">' | wp amp optimizer optimize > output.html
	 *
	 * @param array $args       Array of positional arguments.
	 * @param array $assoc_args Associative array of associative arguments.
	 * @throws WP_CLI\ExitException If the requested file could not be read.
	 */
	public function optimize( $args, /** @noinspection PhpUnusedParameterInspection */ $assoc_args ) {
		$file = '-';

		if ( count( $args ) > 0 ) {
			$file = array_shift( $args );
		}

		if (
			'-' !== $file
			&&
			(
				! is_file( $file )
				||
				! is_readable( $file )
			)
		) {
			WP_CLI::error( "Could not read file: '{$file}'." );
		}

		if ( '-' === $file ) {
			$file = 'php://stdin';
		}

		$html           = file_get_contents( $file );
		$errors         = new ErrorCollection();
		$optimized_html = $this->optimizer_service->optimizeHtml( $html, $errors );

		WP_CLI::line( $optimized_html );

		/** @var Error $error */
		foreach ( $errors as $error ) {
			WP_CLI::warning( "[{$error->getCode()}] {$error->getMessage()}" );
		}
	}
}

Spamworldpro Mini