GRAYBYTE WORDPRESS FILE MANAGER7752

Server IP : 198.54.121.189 / Your IP : 216.73.216.112
System : Linux premium69.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
PHP Version : 7.4.33
Disable Function : NONE
cURL : ON | WGET : ON | Sudo : OFF | Pkexec : OFF
Directory : /home/giriqfky/nioscentre.in/wp-content/plugins/woocommerce/src/Blocks/Patterns/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/nioscentre.in/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/';

	/**
	 * 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 );

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

		return $decoded_body;
	}
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
June 24 2025 08:34:22
giriqfky / giriqfky
0755
AIPatterns.php
0.221 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
PTKClient.php
1.78 KB
September 23 2024 20:44:04
giriqfky / giriqfky
0644
PTKPatternsStore.php
7.813 KB
November 12 2024 21:55:52
giriqfky / giriqfky
0644
PatternRegistry.php
5.236 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF