Skip to content

Instantly share code, notes, and snippets.

@gyrus gyrus/free.php
Created Jun 18, 2015

Embed
What would you like to do?
Free custom filter for Events Calendar Pro Filter Bar
<?php
/**
* Free? filter
*
* @package Young_Hackney
* @since 0.1
*/
class TribeEventsFilter_Free extends TribeEventsFilter {
public $type = 'checkbox';
/**
* Output the admin form
*
* @return string
*/
public function get_admin_form() {
$title = $this->get_title_field();
return $title;
}
/**
* Populate the filter with values
*
* @return array
*/
protected function get_values() {
$values = array(
array(
'name' => __( 'Free' ),
'value' => 1
)
);
return $values;
}
/**
* Pass through the args for the query
*/
protected function setup_query_args() {
$this->queryArgs = array(
'meta_query' => array(
'relation' => 'OR',
array(
'key' => '_EventCost',
'value' => 0,
'compare' => '=',
'type' => 'NUMERIC'
),
array(
'key' => '_EventCost',
'compare' => 'NOT EXISTS',
),
)
);
}
}
// This adds our new filter to the Filterbar options
// Invokes TribeEventsFilter::__construct($name, $slug);
$yh_free = new TribeEventsFilter_Free( 'Free', 'free' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.