Created
June 18, 2015 09:36
-
-
Save gyrus/af981f6e3ab19a940b59 to your computer and use it in GitHub Desktop.
Free custom filter for Events Calendar Pro Filter Bar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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