Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

LLMS_Awards_Query::prepare_meta_query_for_relationships()

Retrieve meta query parts for related posts, engagements, and templates.


Return Return

(array) An array of meta query arrays.


Top ↑

Source Source

File: includes/class-llms-awards-query.php

	private function prepare_meta_query_for_relationships() {

		$meta_query = array();

		$relations = array(
			'related_posts' => '_llms_related',
			'engagements'   => '_llms_engagement',
		);
		foreach ( $relations as $arg => $meta_key ) {

			// Include.
			if ( ! empty( $this->get( $arg ) ) ) {
				$meta_query[] = array(
					'key'     => $meta_key,
					'value'   => $this->sanitize_id_array( $this->get( $arg ) ),
					'compare' => 'IN',
				);
			}

			// Exclude.
			$exclude_arg = $arg . '__exclude';
			if ( ! empty( $this->get( $exclude_arg ) ) ) {

				$meta_query[] = array(
					'relation' => 'OR',
					array(
						'key'     => $meta_key,
						'value'   => $this->sanitize_id_array( $this->get( $exclude_arg ) ),
						'compare' => 'NOT IN',
					),
					// Ensure posts that don't have the metadata set will be returned.
					array(
						'key'     => $meta_key,
						'compare' => 'NOT EXISTS',
					),
				);
			}
		}

		return $meta_query;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.