Compare commits
No commits in common. "1695c5383770f338571c6f27f1f3980fb19298e0" and "de60c363e3fd17cf1233a2973523571c879d9d35" have entirely different histories.
1695c53837
...
de60c363e3
|
@ -18,8 +18,9 @@
|
||||||
* @package Oficina_de_Suport_theme
|
* @package Oficina_de_Suport_theme
|
||||||
*/
|
*/
|
||||||
?>
|
?>
|
||||||
<?php
|
|
||||||
if( ! function_exists( 'ofisuport_ajuts_filters_form') ) {
|
<?php
|
||||||
|
if( ! function_exists( 'ofisuport_ajuts_filters_form' ) ):
|
||||||
function ofisuport_ajuts_filters_form() {
|
function ofisuport_ajuts_filters_form() {
|
||||||
?>
|
?>
|
||||||
<div id="archive-filters" class="ofisuport-filters">
|
<div id="archive-filters" class="ofisuport-filters">
|
||||||
|
@ -30,76 +31,80 @@ if( ! function_exists( 'ofisuport_ajuts_filters_form') ) {
|
||||||
?>
|
?>
|
||||||
<?php // start the form ?>
|
<?php // start the form ?>
|
||||||
<form id="form-ajuts" name="search-ajuts">
|
<form id="form-ajuts" name="search-ajuts">
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$groupkey_fields = acf_get_fields($groupkey);
|
$groupkey_fields = acf_get_fields($groupkey);
|
||||||
foreach( $groupkey_fields as $field_key ) {
|
foreach( $groupkey_fields as $field_key ) {
|
||||||
|
|
||||||
if( $field_key['type'] == 'checkbox' ){
|
if( $field_key['type'] == 'checkbox' ){
|
||||||
|
|
||||||
// https://wordpress.stackexchange.com/a/102915
|
// https://wordpress.stackexchange.com/a/102915
|
||||||
$fields = get_field_object($field_key['key']);
|
$fields = get_field_object($field_key['key']);
|
||||||
if( $fields ) {
|
if( $fields ) {
|
||||||
|
|
||||||
// check for values from meta fields db in url
|
// check for values from meta fields db in url
|
||||||
foreach( $GLOBALS['my_query_filters'] as $key => $fieldname ) {
|
foreach( $GLOBALS['my_query_filters'] as $key => $fieldname ) {
|
||||||
|
|
||||||
// check for values in url and get value if available
|
// check for values in url and get value if available
|
||||||
if( isset($_GET[ $fieldname ]) ) {
|
if( isset($_GET[ $fieldname ]) ) {
|
||||||
|
|
||||||
$filteredvalues['value'] = explode(',', $_GET[ $fieldname ]);
|
$filteredvalues['value'] = explode(',', $_GET[ $fieldname ]);
|
||||||
};
|
};
|
||||||
//end check for values in url
|
//end check for values in url
|
||||||
|
|
||||||
// construct the checkboxes
|
// construct the checkboxes
|
||||||
if( $fieldname == $fields['name']) {
|
if( $fieldname == $fields['name']) {
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<section id="fund-filter-<?php echo $fields['name']; ?>" class="<?php echo $fields['name']; ?>">
|
<section id="fund-filter-<?php echo $fields['name']; ?>" class="<?php echo $fields['name']; ?>">
|
||||||
<h5><?php echo $fields['label'];?></h5>
|
<h5><?php echo $fields['label'];?></h5>
|
||||||
<?php foreach( $fields['choices'] as $choicevalue => $choicelabel ) { ?>
|
<?php foreach( $fields['choices'] as $choicevalue => $choicelabel ) { ?>
|
||||||
|
|
||||||
<div class="filter" data-filter="<?php echo $fields['name'];?>">
|
<div class="filter" data-filter="<?php echo $fields['name'];?>">
|
||||||
<input class="ofisuport-filter" type="checkbox" name="<?php echo $fields['name'];?>" <?php if( in_array($choicevalue,$filteredvalues['value']) ) { echo 'checked';}; ?> value="<?php echo $choicevalue ?>" />
|
<input class="ofisuport-filter" type="checkbox" name="<?php echo $fields['name'];?>" <?php if( in_array($choicevalue,$filteredvalues['value']) ) { echo 'checked';}; ?> value="<?php echo $choicevalue ?>" />
|
||||||
<label for="<?php echo $choicevalue; ?>"><?php echo $choicelabel;?></label>
|
<label for="<?php echo $choicevalue; ?>"><?php echo $choicelabel;?></label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php };//end foreach fields['choices'] ?>
|
<?php };//end foreach fields['choices'] ?>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<?php }; //end if fieldname == fields['name'] ?>
|
<?php }; //end if fieldname == fields['name'] ?>
|
||||||
<?php // end of construct checkboxes ?>
|
<?php // end of construct checkboxes ?>
|
||||||
|
|
||||||
<?php }; // end check for values from meta fields db in url ?>
|
<?php }; // end check for values from meta fields db in url ?>
|
||||||
|
|
||||||
<?php }; //end if field_key['key'] ?>
|
<?php }; //end if field_key['key'] ?>
|
||||||
|
|
||||||
<?php }; //end if type checkbox ?>
|
<?php }; //end if type checkbox ?>
|
||||||
|
|
||||||
<?php }; //end foreach groupkey field ?>
|
<?php }; //end foreach groupkey field ?>
|
||||||
<?php //echo '<p><span id="filterlink"></span></p>';?>
|
<?php //echo '<p><span id="filterlink"></span></p>';?>
|
||||||
<p><a id="submitfilteredlink" name="submit-ajut" class="button button-more" href="">enviar</a> </p>
|
<p><a id="submitfilteredlink" name="submit-ajut" class="button button-more" href="">enviar</a> </p>
|
||||||
</form>
|
</form>
|
||||||
<?php //close the form and subit ?>
|
<?php //close the form and subit ?>
|
||||||
|
|
||||||
<?php }; //end if groupkey ?>
|
<?php }; //end if groupkey ?>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
// change
|
// change
|
||||||
|
//$('#archive-filters').on('click', 'button', function(){
|
||||||
$('#archive-filters').on('click', 'input', function(){
|
$('#archive-filters').on('click', 'input', function(){
|
||||||
|
|
||||||
// vars
|
// vars
|
||||||
var url = '<?php echo home_url('ajuts/'); ?>';
|
var url = '<?php echo home_url('ajuts/'); ?>';
|
||||||
args = {};
|
args = {};
|
||||||
var appendtoURL = '';
|
var appendtoURL = '';
|
||||||
var eachfiltered = '';
|
var eachfiltered = '';
|
||||||
var valueschecked = '';
|
var valueschecked = '';
|
||||||
|
|
||||||
// loop over filters
|
// loop over filters
|
||||||
$('#archive-filters .filter').each(function(){
|
$('#archive-filters .filter').each(function(){
|
||||||
// check if is first appearance of each
|
// check if is first appearance of each
|
||||||
|
@ -112,7 +117,7 @@ if( ! function_exists( 'ofisuport_ajuts_filters_form') ) {
|
||||||
};
|
};
|
||||||
// start new fieldname filtered
|
// start new fieldname filtered
|
||||||
eachfiltered = $(this).data('filter');
|
eachfiltered = $(this).data('filter');
|
||||||
// reset values
|
// reset values
|
||||||
valueschecked = '';
|
valueschecked = '';
|
||||||
// find checked inputs
|
// find checked inputs
|
||||||
$(this).find('input:checked').each(function(){
|
$(this).find('input:checked').each(function(){
|
||||||
|
@ -139,26 +144,26 @@ if( ! function_exists( 'ofisuport_ajuts_filters_form') ) {
|
||||||
valueschecked = valueschecked.slice(0, -1);
|
valueschecked = valueschecked.slice(0, -1);
|
||||||
// save last cycled filtered value already calculated field=val01,val02,val03
|
// save last cycled filtered value already calculated field=val01,val02,val03
|
||||||
appendtoURL += eachfiltered +'=' +valueschecked +'&';
|
appendtoURL += eachfiltered +'=' +valueschecked +'&';
|
||||||
|
|
||||||
// remove last &
|
// remove last &
|
||||||
appendtoURL = appendtoURL.slice(0, -1);
|
appendtoURL = appendtoURL.slice(0, -1);
|
||||||
|
|
||||||
// update url
|
// update url
|
||||||
url += '?' +appendtoURL;
|
url += '?' +appendtoURL;
|
||||||
|
|
||||||
// show or modify the url
|
// show or modify the url
|
||||||
//alert( url );
|
//alert( url );
|
||||||
//$('#filterlink').text(url);
|
//$('#filterlink').text(url);
|
||||||
|
|
||||||
// convert a href url to new value
|
// convert a href url to new value
|
||||||
$('#submitfilteredlink').attr('href',url);
|
$('#submitfilteredlink').attr('href',url);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
}; //end ofisuport_ajuts_filters_form
|
}; //end ofisuport_display_filters()
|
||||||
}; // end if ! functions_exists
|
endif; // end if ! functionexists
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue