added suppor for plugin filtering search
This commit is contained in:
parent
bb3de98e62
commit
7a44843935
|
@ -0,0 +1,106 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* The template for displaying archive custom post type ajut
|
||||||
|
*
|
||||||
|
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
|
||||||
|
*
|
||||||
|
* @package Oficina_de_Suport_theme
|
||||||
|
*/
|
||||||
|
|
||||||
|
get_header();
|
||||||
|
?>
|
||||||
|
|
||||||
|
<main id="primary" class="site-main">
|
||||||
|
|
||||||
|
<section id="filteredfunds" class="ofisuport-filtered-funds ofisuport-ajuts-filtrats">
|
||||||
|
|
||||||
|
<aside id="fundsfilter" class="ofisuport-filter-funds ofisuport-fitre-ajuts">
|
||||||
|
|
||||||
|
<div id="arhive-filters" class="ofisuport-filters">
|
||||||
|
<?php
|
||||||
|
// output all possible values of a checkbox
|
||||||
|
$groupkey = "group_63ab636898703"; // write here the key for the group of fields from acf
|
||||||
|
if( $groupkey){
|
||||||
|
//echo '<h6>check the groupkey <span style="color: #00b">' . $groupkey . '</span></h6>';
|
||||||
|
$groupkey_fields = acf_get_fields($groupkey);
|
||||||
|
foreach( $groupkey_fields as $field_key ) {
|
||||||
|
if( $field_key['type'] == 'checkbox' ){
|
||||||
|
//echo '<span style="color: #00b">' . ($field_key['key']) . '</span><br/>';
|
||||||
|
//echo '<span style="color: #00b">' . ($field_key['label']) . '</span><br/>';
|
||||||
|
//echo '<span style="color: #00b">' . ($field_key['name']) . '</span><br/>';
|
||||||
|
// https://wordpress.stackexchange.com/a/102915
|
||||||
|
//$field_key = "field_XXXXXX";// the acf field key unic numbers
|
||||||
|
$field_key = $field_key['key'];
|
||||||
|
$fields = get_field_object($field_key);
|
||||||
|
|
||||||
|
if( $fields )
|
||||||
|
{
|
||||||
|
// check for values in url
|
||||||
|
foreach( $GLOBALS['my_query_filters'] as $key => $fieldname ):
|
||||||
|
|
||||||
|
// set value if available
|
||||||
|
if( isset($_GET[ $fieldname ]) ) {
|
||||||
|
|
||||||
|
$filteredvalues['value'] = explode(',', $_GET[ $fieldname ]);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// construct the checkboxes
|
||||||
|
if( $fieldname == $fields['name']) {
|
||||||
|
echo '<nav id="fund-filter" class="ofisuport-filter ' . $fields['name'] . '">' ;
|
||||||
|
echo '<h5>' . $fields['label'] . '</h5>';
|
||||||
|
echo '<ul>';
|
||||||
|
|
||||||
|
foreach( $fields['choices'] as $choicevalue => $choicelabel ) {
|
||||||
|
echo '<li>';
|
||||||
|
echo '<input type="checkbox" ';
|
||||||
|
echo ' value="' . $choicevalue . '" ';
|
||||||
|
if( in_array($choicevalue,$filteredvalues['value']) ):
|
||||||
|
echo ' checked="checked" ';
|
||||||
|
endif;
|
||||||
|
echo ' />';
|
||||||
|
echo $choicelabel;
|
||||||
|
echo '</li>';
|
||||||
|
}
|
||||||
|
echo '</ul>';
|
||||||
|
echo '</nav>';
|
||||||
|
};
|
||||||
|
// end of construct checkboxes
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
// end check for values in url
|
||||||
|
}
|
||||||
|
};//end if type checkbox
|
||||||
|
};//end foreach groupkey field
|
||||||
|
};//end if groupkey
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php //endforeach; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<content class="archive-posts <?php ofisuport_class_posttype(); ?>">
|
||||||
|
|
||||||
|
<?php if ( have_posts() ) : ?>
|
||||||
|
<?php while ( have_posts() ) : the_post();
|
||||||
|
|
||||||
|
get_template_part( 'template-parts/section', 'eachpost' );
|
||||||
|
|
||||||
|
endwhile;
|
||||||
|
|
||||||
|
|
||||||
|
else :
|
||||||
|
|
||||||
|
get_template_part( 'template-parts/content', 'none' );
|
||||||
|
|
||||||
|
endif;
|
||||||
|
?>
|
||||||
|
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
</main><!-- #main -->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
get_footer();
|
|
@ -11,72 +11,19 @@ get_header();
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<main id="primary" class="site-main">
|
<main id="primary" class="site-main">
|
||||||
|
<?php
|
||||||
|
// Detect plugin. For use on Front End only.
|
||||||
|
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
||||||
|
// check for plugin using plugin name
|
||||||
|
if ( is_plugin_active( 'oficinasuport-wp-plugin/ofisuport-wp-plugin.php' ) ) {
|
||||||
|
//plugin is activated do
|
||||||
|
?>
|
||||||
|
|
||||||
<section id="filteredfunds" class="ofisuport-filtered-funds ofisuport-ajuts-filtrats">
|
<section id="filteredfunds" class="ofisuport-filtered-funds ofisuport-ajuts-filtrats">
|
||||||
|
|
||||||
<aside id="fundsfilter" class="ofisuport-filter-funds ofisuport-fitre-ajuts">
|
<aside id="fundsfilter" class="ofisuport-filter-funds ofisuport-fitre-ajuts">
|
||||||
|
|
||||||
<div id="arhive-filters" class="ofisuport-filters">
|
|
||||||
<?php
|
|
||||||
// output all possible values of a checkbox
|
|
||||||
$groupkey = "group_63ab636898703"; // write here the key for the group of fields from acf
|
|
||||||
if( $groupkey){
|
|
||||||
//echo '<h6>check the groupkey <span style="color: #00b">' . $groupkey . '</span></h6>';
|
|
||||||
$groupkey_fields = acf_get_fields($groupkey);
|
|
||||||
foreach( $groupkey_fields as $field_key ) {
|
|
||||||
if( $field_key['type'] == 'checkbox' ){
|
|
||||||
//echo '<span style="color: #00b">' . ($field_key['key']) . '</span><br/>';
|
|
||||||
//echo '<span style="color: #00b">' . ($field_key['label']) . '</span><br/>';
|
|
||||||
//echo '<span style="color: #00b">' . ($field_key['name']) . '</span><br/>';
|
|
||||||
// https://wordpress.stackexchange.com/a/102915
|
|
||||||
//$field_key = "field_XXXXXX";// the acf field key unic numbers
|
|
||||||
$field_key = $field_key['key'];
|
|
||||||
$fields = get_field_object($field_key);
|
|
||||||
|
|
||||||
if( $fields )
|
|
||||||
{
|
|
||||||
// check for values in url
|
|
||||||
foreach( $GLOBALS['my_query_filters'] as $key => $fieldname ):
|
|
||||||
|
|
||||||
// set value if available
|
|
||||||
if( isset($_GET[ $fieldname ]) ) {
|
|
||||||
|
|
||||||
$filteredvalues['value'] = explode(',', $_GET[ $fieldname ]);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
// construct the checkboxes
|
<?php ofisuport_ajuts_filters_form(); // function defined in the plugin ?>
|
||||||
if( $fieldname == $fields['name']) {
|
|
||||||
echo '<nav id="fund-filter" class="ofisuport-filter ' . $fields['name'] . '">' ;
|
|
||||||
echo '<h5>' . $fields['label'] . '</h5>';
|
|
||||||
echo '<ul>';
|
|
||||||
|
|
||||||
foreach( $fields['choices'] as $choicevalue => $choicelabel ) {
|
|
||||||
echo '<li>';
|
|
||||||
echo '<input type="checkbox" ';
|
|
||||||
echo ' value="' . $choicevalue . '" ';
|
|
||||||
if( in_array($choicevalue,$filteredvalues['value']) ):
|
|
||||||
echo ' checked="checked" ';
|
|
||||||
endif;
|
|
||||||
echo ' />';
|
|
||||||
echo $choicelabel;
|
|
||||||
echo '</li>';
|
|
||||||
}
|
|
||||||
echo '</ul>';
|
|
||||||
echo '</nav>';
|
|
||||||
};
|
|
||||||
// end of construct checkboxes
|
|
||||||
|
|
||||||
endforeach;
|
|
||||||
// end check for values in url
|
|
||||||
}
|
|
||||||
};//end if type checkbox
|
|
||||||
};//end foreach groupkey field
|
|
||||||
};//end if groupkey
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php //endforeach; ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
@ -100,6 +47,7 @@ get_header();
|
||||||
</content>
|
</content>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<?php } //end plugin is activated do ?>
|
||||||
</main><!-- #main -->
|
</main><!-- #main -->
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -39,13 +39,11 @@ get_header();
|
||||||
|
|
||||||
<aside id="fundsfilter" class="ofisuport-filter-funds ofisuport-fitre-ajuts">
|
<aside id="fundsfilter" class="ofisuport-filter-funds ofisuport-fitre-ajuts">
|
||||||
<?php include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); if ( is_plugin_active( 'oficinasuport-wp-plugin/ofisuport-wp-plugin.php' ) ) { // if plugin active do?>
|
<?php include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); if ( is_plugin_active( 'oficinasuport-wp-plugin/ofisuport-wp-plugin.php' ) ) { // if plugin active do?>
|
||||||
<nav class="sidebar fund-filter">
|
|
||||||
|
|
||||||
</nav>
|
|
||||||
|
<?php ofisuport_ajuts_filters_form(); // function defined in the plugin ?>
|
||||||
|
|
||||||
<?php } //end if is_plugin_active ?>
|
<?php } //end if is_plugin_active ?>
|
||||||
|
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,17 +67,6 @@ get_header();
|
||||||
|
|
||||||
<?php get_template_part( 'template-parts/section', 'eachpost' ); ?>
|
<?php get_template_part( 'template-parts/section', 'eachpost' ); ?>
|
||||||
|
|
||||||
<?php
|
|
||||||
//the_title('<h3>','</h3>');
|
|
||||||
// echo '<ul>';
|
|
||||||
//$postmetas = get_post_meta(get_the_ID());
|
|
||||||
// foreach($postmetas as $meta_key=>$meta_value) {
|
|
||||||
// echo '<li><code>' . $meta_key . '</code>:<code>' . $meta_value[0] . '</code></li>';
|
|
||||||
// } ;
|
|
||||||
// echo '</ul>';
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
<?php endwhile;//end of the loop ?>
|
<?php endwhile;//end of the loop ?>
|
||||||
<?php wp_reset_postdata(); ?>
|
<?php wp_reset_postdata(); ?>
|
||||||
<?php endif; //end query ajut ?>
|
<?php endif; //end query ajut ?>
|
||||||
|
|
Loading…
Reference in New Issue