HEX
Server: LiteSpeed
System: Linux server315.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: globfdxw (6114)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: /home/globfdxw/www/wp-content/plugins/acfml/classes/strategy/repeater-sync/CheckboxCondition.php
<?php

namespace ACFML\Repeater\Sync;

use ACFML\FieldGroup\Mode;
use ACFML\Helper\FieldGroup;
use ACFML\Repeater\Shuffle\Strategy;

class CheckboxCondition {

	/**
	 * @var Strategy
	 */
	private $shuffled;

	public function __construct( Strategy $shuffled ) {
		$this->shuffled = $shuffled;
	}

	/**
	 * @param  string|int $objectId
	 * @param  array      $fieldGroups
	 *
	 * @return bool
	 */
	public function isMet( $objectId, $fieldGroups ) {
		if ( ! in_array( Mode::getForFieldGroups( $fieldGroups ), [ Mode::ADVANCED, Mode::MIXED ], true ) ) {
			return false;
		}

		if (
			! $this->shuffled->isOriginal( $objectId )
			|| ! $this->shuffled->hasTranslations( $objectId )
		) {
			return false;
		}

		$groupHasFieldOfTypes = function( $groupId ) {
			return FieldGroup::hasFieldOfTypes( $groupId, [ 'repeater', 'flexible_content' ] );
		};

		return (bool) wpml_collect( $fieldGroups )
			->pluck( 'ID' )
			->first( $groupHasFieldOfTypes );
	}

}