HEX
Server: Apache
System: Linux sxb1plmcpnl510113.prod.sxb1.secureserver.net 4.18.0-553.58.1.lve.el8.x86_64 #1 SMP Fri Jul 4 12:07:06 UTC 2025 x86_64
User: acnbijigo78q (10488831)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: /home/acnbijigo78q/public_html/wp-content/plugins/acfml/classes/Helper/FieldGroup.php
<?php

namespace ACFML\Helper;

use WPML\API\Sanitize;
use WPML\FP\Obj;

class FieldGroup {

	const CPT         = 'acf-field-group';
	const SCREEN_SLUG = 'acf-field-group';

	/**
	 * @return bool
	 */
	public static function isScreen() {
		return acf_is_screen( self::SCREEN_SLUG );
	}

	/**
	 * @return bool
	 */
	public static function isListScreen() {
		global $pagenow;

		return 'edit.php' === $pagenow
			&& self::SCREEN_SLUG === Sanitize::stringProp( 'post_type', $_GET ); // phpcs:ignore
	}

	/**
	 * @param  int $id
	 *
	 * @return int|null
	 */
	public static function getId( $id ) {
		$group = acf_get_field_group( $id );

		if ( $group ) {
			return (int) Obj::prop( 'ID', $group );
		} else {
			$parentId = (int) Obj::prop( 'ID', get_post_parent( $id ) );

			if ( $parentId ) {
				return self::getId( $parentId );
			}
		}

		return null;
	}

	/**
	 * @return bool
	 */
	public static function isTranslatable() {
		return is_post_type_translated( self::CPT );
	}

	/**
	 * @param  int   $id
	 * @param  array $fieldTypes
	 *
	 * @return bool
	 */
	public static function hasFieldOfTypes( $id, $fieldTypes ) {
		$fieldsInGroup = acf_get_fields( $id );

		if ( empty( $fieldsInGroup ) ) {
			return false;
		}

		return (bool) wpml_collect( $fieldTypes )
			->first( function( $type ) use ( $fieldsInGroup ) {
				return Fields::containsType( $fieldsInGroup, $type );
			} );
	}
}