Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

Commit

Permalink
[#1301] - enable cache through so widget
Browse files Browse the repository at this point in the history
  • Loading branch information
samvthom16 committed Jul 12, 2018
1 parent fcd2587 commit ddc6873
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function get_default_atts(){
'primary_filter' => '',
'secondary_filter' => '',
'showposts' => 100,
//'cache' => '4'
'cache' => '0'
);
}

Expand Down Expand Up @@ -65,4 +65,5 @@ function print_terms_list( $taxonomy, $list_class, $filter_type, $global_text =

}

new AKVO_SHORTCODE_NESTED_FILTERS;
global $akvo_shortcode_nested_filters;
$akvo_shortcode_nested_filters = new AKVO_SHORTCODE_NESTED_FILTERS;
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,27 @@ function main_shortcode( $atts ){

}

/* PASS AN ARRAY TO CREATE ATTRIBUTES OF SHORTCODE */
function form_shortcode( $data ){

$default_atts = $this->get_default_atts(); // GET DEFAULT ATTS OF THE SHORTCODE

$shortcode = '['.$this->shortcode.' '; // SHORTCODE STRING START

foreach( $data as $key => $val ){

/* ONLY ADD THOSE KEYS THAT ARE PART OF THE SHORTCODE */
if( array_key_exists( $key, $default_atts ) ){

$val = str_replace("[","[",$val);
$val = str_replace("]","]",$val);

$shortcode .= $key.'="'.$val.'" '; /* SHORTCODE STRING ADD ATTRIBUTES */
}
}
$shortcode .= ']'; /* SHORTCODE STRING END */

return $shortcode;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ function __construct() {
'options' => $this->get_taxonomies(),
'description' => 'Choose Secondary Filter from Wordpress Custom Taxonomies'
),
'cache' => array(
'type' => 'number',
'label' => __( 'Cache expiry time', 'siteorigin-widgets' ),
'default' => '0',
'description' => 'Number of hours for which the cache will remain valid'
),
),

//The $base_folder path string.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php

echo do_shortcode('[akvo_nested_filters title="'.$instance['title'].'" showposts="'.$instance['showposts'].'" post_type="'.$instance['post_type'].'" primary_filter="'.$instance['primary_filter'].'" secondary_filter="'.$instance['secondary_filter'].'"]');
global $akvo_shortcode_nested_filters;

/*
Find the shortcode [akvo_nested_filters] in inc/shortcodes.php
echo do_shortcode( $akvo_shortcode_nested_filters->form_shortcode( $instance ) );

/*
*
* Find the shortcode [akvo_nested_filters] in inc/shortcodes/
*
*/

?>

0 comments on commit ddc6873

Please sign in to comment.