HEX
Server: LiteSpeed
System: Linux eko108.isimtescil.net 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: uyarreklamcomtr (11202)
PHP: 7.4.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/Interactivity.tar
class-wc-interactivity-store.php000064400000002022151547153520013023 0ustar00<?php
/**
 * Manages the initial state of the Interactivity API store in the server and
 * its serialization so it can be restored in the browser upon hydration.
 *
 * It's a private class, exposed by other functions, like `wc_store`.
 *
 * @access private
 */
class WC_Interactivity_Store {
	/**
	 * Store.
	 *
	 * @var array
	 */
	private static $store = array();

	/**
	 * Get store data.
	 *
	 * @return array
	 */
	static function get_data() {
		return self::$store;
	}

	/**
	 * Merge data.
	 *
	 * @param array $data The data that will be merged with the exsisting store.
	 */
	static function merge_data( $data ) {
		self::$store = array_replace_recursive( self::$store, $data );
	}

	/**
	 * Reset the store data.
	 */
	static function reset() {
		self::$store = array();
	}

	/**
	 * Render the store data.
	 */
	static function render() {
		if ( empty( self::$store ) ) {
			return;
		}

		echo sprintf(
			'<script id="wc-interactivity-store-data" type="application/json">%s</script>',
			wp_json_encode( self::$store )
		);
	}
}
load.php000064400000000177151547153520006211 0ustar00<?php
require __DIR__ . '/class-wc-interactivity-store.php';
require __DIR__ . '/store.php';
require __DIR__ . '/scripts.php';
scripts.php000064400000003264151547153520006761 0ustar00<?php
/**
 * Move interactive scripts to the footer. This is a temporary measure to make
 * it work with `wc_store` and it should be replaced with deferred scripts or
 * modules.
 */
function woocommerce_interactivity_move_interactive_scripts_to_the_footer() {
	// Move the @woocommerce/interactivity package to the footer.
	wp_script_add_data( 'wc-interactivity', 'group', 1 );

	// Move all the view scripts of the interactive blocks to the footer.
	$registered_blocks = \WP_Block_Type_Registry::get_instance()->get_all_registered();
	foreach ( array_values( $registered_blocks ) as $block ) {
		if ( isset( $block->supports['interactivity'] ) && $block->supports['interactivity'] ) {
			foreach ( $block->view_script_handles as $handle ) {
				wp_script_add_data( $handle, 'group', 1 );
			}
		}
	}
}
add_action( 'wp_enqueue_scripts', 'woocommerce_interactivity_move_interactive_scripts_to_the_footer', 11 );

/**
 * Register the Interactivity API runtime and make it available to be enqueued
 * as a dependency in interactive blocks.
 */
function woocommerce_interactivity_register_runtime() {
	$plugin_path = \Automattic\WooCommerce\Blocks\Package::get_path();
	$plugin_url  = plugin_dir_url( $plugin_path . '/index.php' );

	$file = 'build/wc-interactivity.js';

	$file_path = $plugin_path . $file;
	$file_url  = $plugin_url . $file;

	if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG && file_exists( $file_path ) ) {
		$version = filemtime( $file_path );
	} else {
		$version = \Automattic\WooCommerce\Blocks\Package::get_version();
	}

	wp_register_script(
		'wc-interactivity',
		$file_url,
		array(),
		$version,
		true
	);
}
add_action( 'wp_enqueue_scripts', 'woocommerce_interactivity_register_runtime' );
store.php000064400000000715151547153520006424 0ustar00<?php
/**
 * Merge data with the exsisting store.
 *
 * @param array $data Data that will be merged with the exsisting store.
 *
 * @return $data The current store data.
 */
function wc_store( $data = null ) {
	if ( $data ) {
		WC_Interactivity_Store::merge_data( $data );
	}
	return WC_Interactivity_Store::get_data();
}

/**
 * Render the Interactivity API store in the frontend.
 */
add_action( 'wp_footer', array( 'WC_Interactivity_Store', 'render' ), 8 );