EVENTOS
_implode );
}
$full_url = $this->calendar_page . $href;
// persist the `lang` parameter if present
if ( isset( $_REQUEST['lang'] ) ) {
$full_url = esc_url_raw( add_query_arg( 'lang', $_REQUEST['lang'], $full_url ) );
}
return $full_url;
}
/**
* Sets that class is used for custom filter.
*
* @param bool $value Expected true or false.
* @param string $uri_particle URI particle identifier.
*
* @return void Method does not return.
*/
public function set_custom_filter( $value, $uri_particle = null ) {
$this->is_custom_filter = $value;
$this->uri_particle = $uri_particle;
}
/**
* Perform some extra manipulation for filter href. Basically if the current
* category is part of the filter, the href will not contain it (because
* clicking on it will actually mean "remove that one from the filter")
* otherwise it will be preserved.
*
* @param array $to_implode
* @return array
*/
private function add_or_remove_category_from_href( array $to_implode ) {
$array_key = $this->uri_particle;
if ( null === $this->uri_particle ) {
$array_key = $this->_current_array_key();
}
// Let's copy the origina cat_ids or tag_ids so we do not affect it
$copy = array();
if ( isset( $this->args[$array_key] ) ) {
$copy = (array)$this->args[$array_key];
}
$key = array_search( $this->term_id, $copy );
// Let's check if we are already filtering for tags / categorys
if( isset( $to_implode[$array_key] ) ) {
if( $key !== false ) {
unset( $copy[$key] );
} else {
$copy[] = $this->term_id;
}
if( empty( $copy ) ) {
unset( $to_implode[$array_key] );
} else {
$to_implode[$array_key] = $array_key . Ai1ec_Uri::DIRECTION_SEPARATOR .
implode( ',', $copy );
}
} else {
$to_implode[$array_key] = $array_key . Ai1ec_Uri::DIRECTION_SEPARATOR . $this->term_id;
}
return $to_implode;
}
/**
* Match current argument key
*
* @return string Name of current argument key
*/
protected function _current_array_key() {
$map = array(
'category' => 'cat',
'tag' => 'tag',
'author' => 'auth',
);
$use_name = '';
foreach ( $map as $value => $name ) {
if ( $this->{'is_' . $value} ) {
$use_name = $name;
break;
}
}
return $use_name . '_ids';
}
/**
* Returns the delimiter character to use if a new query string parameter is
* going to be appended to the URL.
*
* @param string $url URL to parse
*
* @return string
*/
public static function get_param_delimiter_char( $url ) {
return strpos( $url, '?' ) === false ? '?' : '&';
}
}