Uname: Linux premium294.web-hosting.com 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP Wed Mar 26 12:08:09 UTC 2025 x86_64
Software: LiteSpeed
PHP version: 8.1.32 [ PHP INFO ] PHP os: Linux
Server Ip: 104.21.112.1
Your Ip: 216.73.216.223
User: mjbynoyq (1574) | Group: mjbynoyq (1570)
Safe Mode: OFF
Disable Function:
NONE

name : provider.php
<?php defined( 'ABSPATH' ) or die();

class Brizy_Import_Provider {

    const DEMO_URL = 'https://websitebuilder-demo.net/wp-json/demos/v1/';

	private $mainSite;

	public function __construct() {

		if ( class_exists( 'BrizyPro_Admin_WhiteLabel' ) && BrizyPro_Admin_WhiteLabel::_init()->getEnabled() ) {
			$this->mainSite = __bt( 'starter-templates-url', self::DEMO_URL );
		} else {
			$this->mainSite = self::DEMO_URL;
		}
	}

	/**
	 * @throws Exception
	 * @return array
	 */
	public function getAllDemos() {
		$request = wp_remote_get( $this->mainSite . 'demos', [
			'headers' => [
				'content-type' => 'application/json'
			],
		] );

		if ( is_wp_error( $request ) ) {
			throw new Exception( $request->get_error_message() );
		}

		if ( 200 !== wp_remote_retrieve_response_code( $request ) ) {
			throw new Exception( ( empty( $request['response']['message'] ) ? 'Invalid response code returned by server demo provider' : $request['response']['message'] ) );
		}

		$demos = json_decode( wp_remote_retrieve_body( $request ), true );

		if ( json_last_error() ) {
			throw new Exception( 'Json Decode Error: ' . json_last_error() );
		}

		if ( empty( $demos ) ) {
			throw new Exception( 'No templates found' );
		}

		$demos['demos'] = array_reverse($demos['demos']);

		return $demos;
	}

	public function getExportUrl( $demo, $key ) {
		return add_query_arg( [ 'id' => $demo, 'key' => $key ], $this->mainSite . 'export' );
	}
}
© 2025 XylotrechusZ