SILENT KILLERPanel

Current Path: > home > codekrsu > > cuddlebuds.lk > wp-content > plugins > woocommerce > src > Internal > Utilities


Operation   : Linux premium131.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
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: /home/codekrsu//cuddlebuds.lk/wp-content/plugins/woocommerce/src/Internal/Utilities

NameTypeSizeLast ModifiedActions
ArrayUtil.php File 2153 bytes January 06 2025 20:19:28.
BlocksUtil.php File 2337 bytes June 23 2025 19:46:28.
COTMigrationUtil.php File 6182 bytes May 12 2025 21:07:28.
DatabaseUtil.php File 16483 bytes September 23 2024 20:44:04.
FilesystemUtil.php File 5306 bytes May 12 2025 15:44:58.
HtmlSanitizer.php File 3171 bytes April 30 2024 19:35:34.
LegacyRestApiStub.php File 6807 bytes December 18 2024 22:19:16.
PluginInstaller.php File 14347 bytes December 18 2024 22:19:16.
Types.php File 2020 bytes December 16 2024 15:24:32.
URL.php File 13419 bytes December 16 2024 15:24:32.
URLException.php File 191 bytes April 20 2022 06:50:54.
Users.php File 9552 bytes June 23 2025 19:46:28.
WebhookUtil.php File 5497 bytes December 18 2024 22:19:16.

Reading File: /home/codekrsu//cuddlebuds.lk/wp-content/plugins/woocommerce/src/Internal/Utilities/BlocksUtil.php

<?php
declare( strict_types = 1 );

namespace Automattic\WooCommerce\Internal\Utilities;

/**
 * Helper functions for working with blocks.
 */
class BlocksUtil {

	/**
	 * Return blocks with their inner blocks flattened.
	 *
	 * @param array $blocks Array of blocks as returned by parse_blocks().
	 * @return array All blocks.
	 */
	public static function flatten_blocks( $blocks ) {
		return array_reduce(
			$blocks,
			function ( $carry, $block ) {
				array_push( $carry, array_diff_key( $block, array_flip( array( 'innerBlocks' ) ) ) );
				if ( isset( $block['innerBlocks'] ) ) {
					$inner_blocks = self::flatten_blocks( $block['innerBlocks'] );
					return array_merge( $carry, $inner_blocks );
				}

				return $carry;
			},
			array()
		);
	}

	/**
	 * Get all instances of the specified block from the widget area.
	 *
	 * @param array $block_name The name (id) of a block, e.g. `woocommerce/mini-cart`.
	 * @return array Array of blocks as returned by parse_blocks().
	 */
	public static function get_blocks_from_widget_area( $block_name ) {
		$blocks = get_option( 'widget_block' );

		if ( ! is_array( $blocks ) || empty( $blocks ) ) {
			return array();
		}

		return array_reduce(
			$blocks,
			function ( $acc, $block ) use ( $block_name ) {
				$parsed_blocks = ! empty( $block['content'] ) ? parse_blocks( $block['content'] ) : array();
				if ( ! empty( $parsed_blocks ) && $block_name === $parsed_blocks[0]['blockName'] ) {
					array_push( $acc, $parsed_blocks[0] );
				}
				return $acc;
			},
			array()
		);
	}

	/**
	 * Get all instances of the specified block on a specific template part.
	 *
	 * @param string $block_name The name (id) of a block, e.g. `woocommerce/mini-cart`.
	 * @param string $template_part_slug The woo page to search, e.g. `header`.
	 * @return array Array of blocks as returned by parse_blocks().
	 */
	public static function get_block_from_template_part( $block_name, $template_part_slug ) {
		$template = get_block_template( get_stylesheet() . '//' . $template_part_slug, 'wp_template_part' );
		$blocks   = parse_blocks( $template->content );

		$flatten_blocks = self::flatten_blocks( $blocks );

		return array_values(
			array_filter(
				$flatten_blocks,
				function ( $block ) use ( $block_name ) {
					return ( $block_name === $block['blockName'] );
				}
			)
		);
	}
}

SILENT KILLER Tool