HEX
Server: Apache/2
System: Linux ind.multivistaglobal.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: multivis (1002)
PHP: 8.1.32
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/multivis/public_html/wp-content/plugins/popup-maker/classes/Utils/Blocks.php
<?php
/**
 * Block utilities.
 *
 * @since       1.14
 * @package     PUM
 * @copyright   Copyright (c) 2020, Code Atlantic LLC
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Class PUM_Utils_Blocks
 */
class PUM_Utils_Blocks {

	/**
	 * Find blocks with matching name in given list of blocks.
	 *
	 * Recursively searches through WordPress block structures, including nested blocks
	 * within core/columns and core/column containers.
	 *
	 * @param array<string, mixed>[] $blocks Array of WordPress block structures.
	 * @param string                 $search_name Block name to look for (supports wildcards like 'pum/*').
	 *
	 * @return array<string, mixed>[] Array of matching WordPress blocks.
	 */
	public static function find_blocks( $blocks, $search_name = 'pum/*' ) {
		$found_blocks = [];

		foreach ( $blocks as $block ) {
			if ( in_array( $block['blockName'], [ 'core/columns', 'core/column' ], true ) ) {
				$found_blocks = array_merge( $found_blocks, self::find_blocks( $block['innerBlocks'], $search_name ) );
			}

			if ( $search_name === $block['blockName'] ) {
				$found_blocks[] = $block;
			}
		}

		return $found_blocks;
	}
}