GRAYBYTE WORDPRESS FILE MANAGER2696

Server IP : 192.250.235.76 / Your IP : 45.90.210.12
System : Linux s2968.sgp1.stableserver.net 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
PHP Version : 8.2.29
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF

HOME

/home/tawsifschoice/borkaa.tawsifschoice.com/
1902120114081995

GRAYBYTE WORDPRESS FILE MANAGER4589

Server IP : 198.54.116.172 / Your IP : 216.73.216.36
System : Linux server322.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : mail
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF

HOME

/home/sadasgfe/fashiondebate.pk/wp-content/plugins/woocommerce/src/Blocks/Patterns/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/sadasgfe/fashiondebate.pk/wp-content/plugins/woocommerce/src/Blocks/Patterns//PTKClient.php
<?php
namespace Automattic\WooCommerce\Blocks\Patterns;

use WP_Error;

/**
 * PatternsToolkit class.
 *
 * @internal
 */
class PTKClient {
	/**
	 *  The Patterns Toolkit API URL
	 */
	const PATTERNS_TOOLKIT_URL = 'https://public-api.wordpress.com/rest/v1/ptk/patterns/';

	/**
	 * The schema for the patterns toolkit.
	 *
	 * @var array
	 */
	private $schema;

	/**
	 * Constructor.
	 */
	public function __construct() {
		$this->schema = [
			'type'  => 'array',
			'items' => [
				'type'       => 'object',
				'properties' => [
					'ID'         => [
						'type'     => 'integer',
						'required' => true,
					],
					'site_id'    => [
						'type'     => 'integer',
						'required' => true,
					],
					'title'      => [
						'type'     => 'string',
						'required' => true,
					],
					'name'       => [
						'type'     => 'string',
						'required' => true,
					],
					'html'       => [
						'type'     => 'string',
						'required' => true,
					],
					'categories' => [
						'type'                 => 'object',
						'additionalProperties' => [
							'type'       => 'object',
							'properties' => [
								'slug'        => [
									'type'     => 'string',
									'required' => true,
								],
								'title'       => [
									'type'     => 'string',
									'required' => true,
								],
								'description' => [
									'type'     => 'string',
									'required' => true,
								],
							],
						],
					],
				],
			],
		];
	}

	/**
	 * Fetch the WooCommerce patterns from the Patterns Toolkit (PTK) API.
	 *
	 * @param array $options Options for fetching patterns.
	 * @return array|WP_Error
	 */
	public function fetch_patterns( array $options = array() ) {
		$locale = get_user_locale();
		$lang   = preg_replace( '/(_.*)$/', '', $locale );

		$ptk_url = self::PATTERNS_TOOLKIT_URL . $lang;

		if ( isset( $options['site'] ) ) {
			$ptk_url = add_query_arg( 'site', $options['site'], $ptk_url );
		}

		if ( isset( $options['categories'] ) ) {
			$ptk_url = add_query_arg( 'categories', implode( ',', $options['categories'] ), $ptk_url );
		}

		if ( isset( $options['per_page'] ) ) {
			$ptk_url = add_query_arg( 'per_page', $options['per_page'], $ptk_url );
		}

		$patterns = wp_safe_remote_get( $ptk_url );
		if ( is_wp_error( $patterns ) || 200 !== wp_remote_retrieve_response_code( $patterns ) ) {
			return new WP_Error(
				'patterns_toolkit_api_error',
				__( 'Failed to connect with the Patterns Toolkit API: try again later.', 'woocommerce' )
			);
		}

		$body = wp_remote_retrieve_body( $patterns );

		if ( empty( $body ) ) {
			return new WP_Error(
				'patterns_toolkit_api_error',
				__( 'Empty response received from the Patterns Toolkit API.', 'woocommerce' )
			);
		}

		$decoded_body = json_decode( $body, true );

		$is_pattern_payload_valid = $this->is_valid_schema( $decoded_body );

		if ( ! $is_pattern_payload_valid ) {
			return new WP_Error(
				'patterns_toolkit_api_error',
				__( 'Wrong response received from the Patterns Toolkit API: try again later.', 'woocommerce' )
			);
		}

		return $decoded_body;
	}

	/**
	 * Validate the patterns toolkit patterns.
	 *
	 * @param array $patterns The patterns to validate.
	 * @return bool
	 */
	public function is_valid_schema( $patterns ) {
		$is_pattern_payload_valid = rest_validate_value_from_schema( $patterns, $this->schema );

		return ! is_wp_error( $is_pattern_payload_valid );
	}
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
December 22 2025 16:57:26
sadasgfe / sadasgfe
0755
AIPatterns.php
0.221 KB
December 22 2025 16:57:26
sadasgfe / sadasgfe
0644
PTKClient.php
3.343 KB
December 22 2025 16:57:26
sadasgfe / sadasgfe
0644
PTKPatternsStore.php
8.62 KB
December 22 2025 16:57:26
sadasgfe / sadasgfe
0644
PatternRegistry.php
5.236 KB
December 22 2025 16:57:26
sadasgfe / sadasgfe
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF