GRAYBYTE WORDPRESS FILE MANAGER3792

Server IP : 198.54.121.189 / Your IP : 216.73.216.140
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/chahida.co.in/wp-content/plugins/woocommerce/src/Internal/Utilities/
Upload Files :
Current_dir [ Writeable ] Document_root [ Writeable ]

Command :


Current File : /home/giriqfky/chahida.co.in/wp-content/plugins/woocommerce/src/Internal/Utilities//BlocksUtil.php
<?php

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 ) {
		return array_reduce(
			get_option( 'widget_block' ),
			function ( $acc, $block ) use ( $block_name ) {
				$parsed_blocks = ! empty( $block ) && is_array( $block ) ? parse_blocks( $block['content'] ) : array();
				if ( ! empty( $parsed_blocks ) && $block_name === $parsed_blocks[0]['blockName'] ) {
					array_push( $acc, $parsed_blocks[0] );
					return $acc;
				}
				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'] );
				}
			)
		);
	}
}

[ Back ]
Name
Size
Last Modified
Owner / Group
Permissions
Options
..
--
July 10 2025 04:32:19
giriqfky / giriqfky
0755
.htaccess
0.41 KB
July 10 2025 04:32:19
giriqfky / giriqfky
0644
ArrayUtil.php
2.103 KB
January 06 2025 20:19:28
giriqfky / giriqfky
0644
BlocksUtil.php
2.185 KB
May 24 2022 21:38:16
giriqfky / giriqfky
0644
COTMigrationUtil.php
6.037 KB
May 12 2025 21:07:28
giriqfky / giriqfky
0644
DatabaseUtil.php
16.097 KB
September 23 2024 20:44:04
giriqfky / giriqfky
0644
FilesystemUtil.php
5.182 KB
May 12 2025 15:44:58
giriqfky / giriqfky
0644
HtmlSanitizer.php
3.097 KB
April 30 2024 19:35:34
giriqfky / giriqfky
0644
LegacyRestApiStub.php
6.647 KB
December 18 2024 22:19:16
giriqfky / giriqfky
0644
PluginInstaller.php
14.011 KB
December 18 2024 22:19:16
giriqfky / giriqfky
0644
Types.php
1.973 KB
December 16 2024 15:24:32
giriqfky / giriqfky
0644
URL.php
13.104 KB
December 16 2024 15:24:32
giriqfky / giriqfky
0644
URLException.php
0.187 KB
April 20 2022 06:50:54
giriqfky / giriqfky
0644
Users.php
7.636 KB
July 10 2024 21:55:32
giriqfky / giriqfky
0644
WebhookUtil.php
5.368 KB
December 18 2024 22:19:16
giriqfky / giriqfky
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025
CONTACT ME
Static GIF