Uncanny_Toolkit_Helpers::get_group_leader_from_data( $values,  $keys )

Group leader meta


Parameters Parameters

$values

(Required)

$keys

(Required)


Top ↑

Return Return

(array[])


Source Source

File: src/integrations/uncanny-toolkit/helpers/uncanny-toolkit-helpers.php

	public static function get_group_leader_from_data( $values, $keys ) {
		$ids    = array();
		$titles = array();
		$return = array(
			'group_ids'    => $ids,
			'group_titles' => $titles,
		);

		if ( ! isset( $keys['group_leader'] ) ) {
			return $return;
		}

		$k = $keys['group_leader'];
		if ( ! isset( $values[ $k ] ) ) {
			return $return;
		}
		if ( empty( $values[ $k ] ) ) {
			return $return;
		}
		$learndash_groups = explode( ';', $values[ $k ] );
		if ( empty( $learndash_groups ) || is_numeric( $values[ $k ] ) ) {
			$ids[]    = $values[ $k ];
			$titles[] = get_the_title( $values[ $k ] );
		} else {
			foreach ( $learndash_groups as $g ) {
				$ids[]    = $g;
				$titles[] = get_the_title( $g );
			}
		}

		return array(
			'group_ids'    => $ids,
			'group_titles' => $titles,
		);
	}