cliff
10/27/2018 - 5:25 AM

The Events Calendar (TEC) and Event Aggregator (EA): Add further-future import limits.

The Events Calendar (TEC) and Event Aggregator (EA): Add further-future import limits.

<?php
/**
 * The Events Calendar (TEC) and Event Aggregator (EA): Add further-future import limits.
 *
 * @link https://gist.github.com/cliffordp/7e687ec1d1cd7d89d2fa05af5b595d1f This snippet.
 *
 * @see  \Tribe__Events__Aggregator__Settings::get_range_options()
 */
function cliff_ea_add_further_future_import_range_options( $options ) {
	// Add months 4-11
	for ( $i = 4; $i <= 11; $i ++ ) {
		$text = sprintf( '%d months', $i );

		$options[$i * MONTH_IN_SECONDS] = [
			'title' => $text,
			'range' => $text,
		];
	}

	// add 1 year
	$options[YEAR_IN_SECONDS] = [
		'title' => '1 Year',
		'range' => '1 year',
	];

	// add 2 years
	$options[2 * YEAR_IN_SECONDS] = [
		'title' => '2 Years',
		'range' => '2 years',
	];

	return $options;
}

// wp-admin > Events > Settings > Imports tab > "Global Import Settings" section
add_action( 'tribe_aggregator_import_range_options', 'cliff_ea_add_further_future_import_range_options' );
// wp-admin > Events > Settings > Imports tab > "Other URL Import Settings" section
add_action( 'tribe_aggregator_url_import_range_options', 'cliff_ea_add_further_future_import_range_options' );