HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/lipovac/wp-content/plugins/the-events-calendar/src/Tribe/Repositories/Linked_Posts.php
<?php
/**
 * The main ORM/Repository class for linked posts.
 *
 * @since 4.9
 */

/**
 * Class Tribe__Events__Repositories__Linked_Posts
 *
 *
 * @since 4.9
 */
class Tribe__Events__Repositories__Linked_Posts extends Tribe__Repository {

	/**
	 * The unique fragment that will be used to identify this repository filters.
	 *
	 * @var string
	 */
	protected $filter_name = 'linked_posts';

	/**
	 * Meta key used to store the Linked Post ID.
	 *
	 * @var string
	 */
	protected $linked_id_meta_key;

	/**
	 * Tribe__Events__Repositories__Linked_Posts constructor.
	 *
	 * Sets up the repository default parameters and schema.
	 *
	 * @since 4.9
	 */
	public function __construct() {
		parent::__construct();

		$this->default_args = array(
			'post_type'                    => Tribe__Events__Venue::POSTTYPE,
			// We'll be handling the dates, let's mark the query as a non-filtered one.
			'tribe_suppress_query_filters' => true,
		);

		$this->schema = array_merge( $this->schema, array(
			'event' => array( $this, 'filter_by_event' ),
		) );
	}

	/**
	 * Filters linked post types by a specific event of set of events.
	 *
	 * @since 4.9
	 *
	 * @param int|WP_Post|array $event Post ID, Post Object, or an array of Post IDs or Objects.
	 */
	public function filter_by_event( $event ) {
		if ( ! $this->linked_id_meta_key ) {
			return;
		}

		$events = (array) $event;

		$post_ids = array_map( array( 'Tribe__Main', 'post_id_helper' ), $events );
		$post_ids = array_filter( $post_ids );
		$post_ids = array_unique( $post_ids );

		if ( empty( $post_ids ) ) {
			return;
		}

		$in_pattern = array_fill( 0, count( $post_ids ), '%d' );
		$in_pattern = implode( ', ', $in_pattern );

		global $wpdb;

		$this->filter_query->join(
			$wpdb->prepare(
				"
					JOIN {$wpdb->postmeta} linked_posts_event
					ON ( {$wpdb->posts}.ID = linked_posts_event.meta_value AND linked_posts_event.meta_key = %s )
				",
				$this->linked_id_meta_key
			)
		);

		$this->filter_query->where(
			$wpdb->prepare(
				"linked_posts_event.post_id IN ( {$in_pattern} )",
				$post_ids
			)
		);
	}

}