From ddc68737ba1f282ec6bd734c5166774dd56c067e Mon Sep 17 00:00:00 2001 From: Samuel Thomas Date: Thu, 12 Jul 2018 16:19:28 +0530 Subject: [PATCH] [#1301] - enable cache through so widget --- .../class-akvo-shortcode-nested-filters.php | 5 ++-- .../inc/shortcodes/class-akvo-shortcode.php | 23 +++++++++++++++++++ .../akvo-nested-filters.php | 6 +++++ .../templates/template.php | 10 ++++---- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/code/wp-content/themes/Akvo-responsive/inc/shortcodes/class-akvo-shortcode-nested-filters.php b/code/wp-content/themes/Akvo-responsive/inc/shortcodes/class-akvo-shortcode-nested-filters.php index c91aef69..edf77eef 100644 --- a/code/wp-content/themes/Akvo-responsive/inc/shortcodes/class-akvo-shortcode-nested-filters.php +++ b/code/wp-content/themes/Akvo-responsive/inc/shortcodes/class-akvo-shortcode-nested-filters.php @@ -21,7 +21,7 @@ function get_default_atts(){ 'primary_filter' => '', 'secondary_filter' => '', 'showposts' => 100, - //'cache' => '4' + 'cache' => '0' ); } @@ -65,4 +65,5 @@ function print_terms_list( $taxonomy, $list_class, $filter_type, $global_text = } - new AKVO_SHORTCODE_NESTED_FILTERS; \ No newline at end of file + global $akvo_shortcode_nested_filters; + $akvo_shortcode_nested_filters = new AKVO_SHORTCODE_NESTED_FILTERS; \ No newline at end of file diff --git a/code/wp-content/themes/Akvo-responsive/inc/shortcodes/class-akvo-shortcode.php b/code/wp-content/themes/Akvo-responsive/inc/shortcodes/class-akvo-shortcode.php index ab316d14..5de53772 100644 --- a/code/wp-content/themes/Akvo-responsive/inc/shortcodes/class-akvo-shortcode.php +++ b/code/wp-content/themes/Akvo-responsive/inc/shortcodes/class-akvo-shortcode.php @@ -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; + } + } \ No newline at end of file diff --git a/code/wp-content/themes/Akvo-responsive/so-widgets/akvo-nested-filters/akvo-nested-filters.php b/code/wp-content/themes/Akvo-responsive/so-widgets/akvo-nested-filters/akvo-nested-filters.php index d320ac4b..d8f761a7 100644 --- a/code/wp-content/themes/Akvo-responsive/so-widgets/akvo-nested-filters/akvo-nested-filters.php +++ b/code/wp-content/themes/Akvo-responsive/so-widgets/akvo-nested-filters/akvo-nested-filters.php @@ -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. diff --git a/code/wp-content/themes/Akvo-responsive/so-widgets/akvo-nested-filters/templates/template.php b/code/wp-content/themes/Akvo-responsive/so-widgets/akvo-nested-filters/templates/template.php index 6ce94686..cc6ca295 100644 --- a/code/wp-content/themes/Akvo-responsive/so-widgets/akvo-nested-filters/templates/template.php +++ b/code/wp-content/themes/Akvo-responsive/so-widgets/akvo-nested-filters/templates/template.php @@ -1,11 +1,13 @@ form_shortcode( $instance ) ); + /* + * + * Find the shortcode [akvo_nested_filters] in inc/shortcodes/ + * */ ?>