$plugin = <<403WebShell
403Webshell
Server IP : 193.224.177.188  /  Your IP : 216.73.217.123
Web Server : Apache
System : Linux cpanel.krtk.mta.hu 3.10.0-962.3.2.lve1.5.89.el7.x86_64 #1 SMP Thu Jul 9 15:55:31 UTC 2026 x86_64
User : krtkhu ( 1061)
PHP Version : 8.4.28
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home2/krtkhu/public_html/wp-content/plugins/hellopack-client/includes/Cli/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home2/krtkhu/public_html/wp-content/plugins/hellopack-client/includes/Cli/ThemeCommand.php
<?php
/**
 * WP-CLI theme commands.
 *
 * @package HelloPack\Client
 */

declare( strict_types=1 );

namespace HelloPack\Client\Cli;

use HelloPack\Client\Api\Client;
use HelloPack\Client\Update\Installer;
use HelloPack\Client\Update\ItemsCache;
use HelloPack\Client\Update\SlugResolver;
use WP_CLI;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Manage HelloPack premium themes.
 */
class ThemeCommand {

	/**
	 * API client.
	 *
	 * @var Client
	 */
	private Client $api;

	/**
	 * Items cache.
	 *
	 * @var ItemsCache
	 */
	private ItemsCache $cache;

	/**
	 * Installer service.
	 *
	 * @var Installer
	 */
	private Installer $installer;

	/**
	 * Slug resolver.
	 *
	 * @var SlugResolver
	 */
	private SlugResolver $resolver;

	/**
	 * Constructor.
	 *
	 * @param Client       $api       API client.
	 * @param ItemsCache   $cache     Items cache.
	 * @param Installer    $installer Installer service.
	 * @param SlugResolver $resolver  Slug resolver.
	 */
	public function __construct( Client $api, ItemsCache $cache, Installer $installer, SlugResolver $resolver ) {
		$this->api       = $api;
		$this->cache     = $cache;
		$this->installer = $installer;
		$this->resolver  = $resolver;
	}

	/**
	 * List purchased themes.
	 *
	 * ## OPTIONS
	 *
	 * [--format=<format>]
	 * : Render output in a particular format.
	 * ---
	 * default: table
	 * options:
	 *   - table
	 *   - csv
	 *   - json
	 *   - yaml
	 * ---
	 *
	 * ## EXAMPLES
	 *
	 *     wp hellopack theme list
	 *     wp hellopack theme list --format=json
	 *
	 * @when after_wp_load
	 * @subcommand list
	 *
	 * @param array<int, string>    $args       Positional arguments.
	 * @param array<string, string> $assoc_args Associative arguments.
	 */
	public function list_( array $args, array $assoc_args ): void {
		$format  = $assoc_args['format'] ?? 'table';
		$grouped = $this->cache->get_themes( true );

		if ( empty( $grouped['purchased'] ) ) {
			WP_CLI::error( __( 'No purchased themes found.', 'hellopack-client' ) );
		}

		$items = array();
		foreach ( $grouped['purchased'] as $theme ) {
			$slug    = $theme['slug'] ?? sanitize_title( $theme['name'] );
			$items[] = array(
				'id'      => $theme['id'],
				'name'    => $theme['name'],
				'slug'    => $slug,
				'version' => $theme['version'] ?? 'N/A',
				'status'  => $this->get_theme_status( $slug, $grouped ),
			);
		}

		WP_CLI\Utils\format_items( $format, $items, array( 'id', 'name', 'slug', 'version', 'status' ) );
	}

	/**
	 * Install a theme from HelloPack.
	 *
	 * ## OPTIONS
	 *
	 * <theme>...
	 * : One or more theme slugs or numeric IDs.
	 *
	 * [--activate]
	 * : Activate the theme after installation.
	 *
	 * ## EXAMPLES
	 *
	 *     wp hellopack theme install bricks
	 *     wp hellopack theme install 123 --activate
	 *
	 * @when after_wp_load
	 *
	 * @param array<int, string>    $args       Positional arguments.
	 * @param array<string, string> $assoc_args Associative arguments.
	 */
	public function install( array $args, array $assoc_args ): void {
		$activate = isset( $assoc_args['activate'] );
		$failed   = 0;

		foreach ( $args as $identifier ) {
			if ( ! $this->install_one( (string) $identifier, $activate ) ) {
				++$failed;
			}
		}

		if ( count( $args ) < 2 ) {
			if ( $failed > 0 ) {
				WP_CLI::halt( 1 );
			}
			return;
		}

		$installed = count( $args ) - $failed;
		$message   = sprintf(
			/* translators: 1: number installed, 2: total number requested. */
			__( 'Installed %1$d of %2$d themes.', 'hellopack-client' ),
			$installed,
			count( $args )
		);

		if ( $failed > 0 ) {
			WP_CLI::error( $message );
		}

		WP_CLI::success( $message );
	}

	/**
	 * Install one theme and report on it.
	 *
	 * Reports through WP_CLI::warning so a batch carries on after a failure.
	 *
	 * @param string $identifier Theme slug or numeric ID.
	 * @param bool   $activate   Activate after installation.
	 * @return bool Whether the theme was installed.
	 */
	private function install_one( string $identifier, bool $activate ): bool {

		$theme_info = $this->resolver->resolve_theme( $identifier, true );

		if ( null === $theme_info ) {
			WP_CLI::warning(
				sprintf(
					/* translators: %s: theme slug or ID */
					__( 'Theme "%s" not found in purchased items.', 'hellopack-client' ),
					$identifier
				)
			);
			return false;
		}

		WP_CLI::log(
			sprintf(
			/* translators: %s: theme name */
				__( 'Installing theme: %s', 'hellopack-client' ),
				$theme_info['name']
			)
		);

		$result = $this->installer->install_theme( (int) $theme_info['id'], $activate );

		if ( empty( $result['success'] ) ) {
			WP_CLI::warning( (string) ( $result['message'] ?? __( 'Theme installation failed.', 'hellopack-client' ) ) );
			return false;
		}

		WP_CLI::success(
			sprintf(
			/* translators: %s: theme name */
				__( 'Theme "%s" installed successfully.', 'hellopack-client' ),
				$theme_info['name']
			)
		);

		if ( $activate && ! empty( $result['switched'] ) ) {
			WP_CLI::success(
				sprintf(
				/* translators: %s: theme name */
					__( 'Theme "%s" activated.', 'hellopack-client' ),
					$theme_info['name']
				)
			);
		}

		return true;
	}

	/**
	 * Update a HelloPack theme.
	 *
	 * ## OPTIONS
	 *
	 * <theme>
	 * : The theme slug to update.
	 *
	 * ## EXAMPLES
	 *
	 *     wp hellopack theme update bricks
	 *
	 * @when after_wp_load
	 *
	 * @param array<int, string> $args Positional arguments.
	 */
	public function update( array $args ): void {
		$slug = $args[0];

		if ( ! preg_match( '/^[a-zA-Z0-9_-]+$/', $slug ) ) {
			WP_CLI::error( __( 'Invalid theme slug.', 'hellopack-client' ) );
		}

		$stylesheet = $this->resolver->find_installed_theme_stylesheet( $slug );

		if ( null === $stylesheet ) {
			WP_CLI::error(
				sprintf(
				/* translators: %s: theme slug */
					__( 'Theme "%s" is not installed.', 'hellopack-client' ),
					$slug
				)
			);
		}

		$result = $this->installer->update_theme( $stylesheet );

		if ( empty( $result['success'] ) ) {
			WP_CLI::error( (string) ( $result['message'] ?? __( 'Theme update failed.', 'hellopack-client' ) ) );
		}

		WP_CLI::success(
			sprintf(
			/* translators: 1: theme slug, 2: from version, 3: to version */
				__( 'Theme "%1$s" updated %2$s → %3$s.', 'hellopack-client' ),
				$slug,
				(string) ( $result['from_version'] ?? '?' ),
				(string) ( $result['to_version'] ?? '?' )
			)
		);
	}

	/**
	 * Determine the installation status of a theme.
	 *
	 * @param string                              $slug    Theme slug.
	 * @param array<string, array<string, mixed>> $grouped Grouped theme data.
	 * @return string 'active', 'installed', or 'available'.
	 */
	private function get_theme_status( string $slug, array $grouped ): string {
		foreach ( $grouped['active'] ?? array() as $theme ) {
			$active_slug = $theme['slug'] ?? sanitize_title( $theme['name'] );
			if ( $active_slug === $slug ) {
				return 'active';
			}
		}

		foreach ( $grouped['installed'] ?? array() as $theme ) {
			$installed_slug = $theme['slug'] ?? sanitize_title( $theme['name'] );
			if ( $installed_slug === $slug ) {
				return 'installed';
			}
		}

		return 'available';
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit