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/Service_Providers/ORM.php
<?php
/**
 * Hooks and registers the functions and implementations needed to provide
 * the ORM/Repository classes.
 *
 * @since 4.9
 */

/**
 * Class Tribe__Events__Service_Providers__ORM
 *
 * @since 4.9
 */
class Tribe__Events__Service_Providers__ORM extends tad_DI52_ServiceProvider {

	/**
	 * Binds and sets up implementations.
	 */
	public function register() {
		require_once tribe( 'tec.main' )->plugin_path . 'src/functions/template-tags/orm.php';

		// Not bound as a singleton to leverage the repository instance properties and to allow decoration and injection.
		$this->container->bind( 'events.event-repository', 'Tribe__Events__Repositories__Event' );
		$this->container->bind( 'events.organizer-repository', 'Tribe__Events__Repositories__Organizer' );
		$this->container->bind( 'events.venue-repository', 'Tribe__Events__Repositories__Venue' );

		add_filter( 'tribe_events_has_next_args', [ $this, 'maybe_remove_date_meta_queries' ], 1, 2 );
		add_filter( 'tribe_events_has_previous_args', [ $this, 'maybe_remove_date_meta_queries' ], 1, 2 );
	}

	/**
	 * Handles next and previous links arguments when generated on a repository-managed query.
	 *
	 * The next and previous links are built by using the global query arguments and slightly altering them.
	 * This approach, when done on the arguments provided by a repository generated query, might yield duplicated
	 * meta queries that will, in turn, return wrong results.
	 * The arguments will be already set in the arguments of the query.
	 *
	 * @since 4.9
	 *
	 * @param array          $args An array of query arguments that will be used to check if there are next or previous
	 *                             events.
	 * @param \WP_Query|null $query The query the arguments were taken from.
	 *
	 * @return array A filtered array of arguments where the date-related contents of the meta query are removed to
	 *               avoid duplicates.
	 */
	public function maybe_remove_date_meta_queries( array $args = [], WP_Query $query = null ) {
		if ( empty( $args['meta_query'] ) || ! $query instanceof WP_Query ) {
			return $args;
		}

		if ( empty( $query->builder ) || ! $query->builder instanceof Tribe__Repository__Interface ) {
			return $args;
		}

		$args['meta_query'] = tribe_filter_meta_query(
			$args['meta_query'],
			[ 'key' => '/_Event(Start|End)Date(UTC)*/' ]
		);

		return $args;
	}
}