Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions includes/class-calendar-plus-dates-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,10 @@ public static function delete_old_dates( $delete_from = false ) {
update_option( 'calendarp_first_date_generated', $delete_from );
self::clear_cached_months();
}

// Lets use this opportunity to store the last known total dates
$total_old_dates = (int) $wpdb->get_var( "SELECT COUNT(ID) FROM $table" );
update_option( 'calendarp_last_known_total_dates', $delete_from );
}


Expand Down
9 changes: 8 additions & 1 deletion includes/class-calendar-plus-query.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ class Calendar_Plus_Query {

public function __construct() {

$this->query_vars = array( 'from', 'to', 'location', 'calendarp_searchw', 'order' );
$this->query_vars = array( 'location', 'calendarp_searchw', 'order' );

// "to" and "from" query vars can lead to heavy queries, lets only allow them if total dates is below the limit
$last_known_total_dates = (int) get_option( 'calendarp_last_known_total_dates', 0 );
if( $last_known_total_dates < apply_filters( 'calendarp_heavy_query_vars_total_dates_limit', 500 ) ) {
$this->query_vars[] = 'from';
$this->query_vars[] = 'to';
}

if ( ! is_admin() ) {
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
Expand Down