Skip to content

Commit 6fdc1b7

Browse files
author
Antti Kuosmanen
authored
Merge pull request #12 from k1sul1/upstream
fix #11, added filter & transient
2 parents e6e5651 + 77c9b5a commit 6fdc1b7

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

classes/class-cpt-wplf-submission.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,29 @@ function custom_columns_cpt( $columns ) {
106106
function form_filter_dropdown() {
107107
global $pagenow;
108108

109-
if( 'edit.php' != $pagenow ) {
109+
$allowed = array("wplf-submission"); // show filter on these post types (currently only one?)
110+
$allowed = apply_filters("wplf-dropdown-filter", $allowed);
111+
$post_type = get_query_var("post_type");
112+
113+
if( 'edit.php' != $pagenow || !in_array($post_type, $allowed)) {
110114
return;
111115
}
112116

113-
// TODO: put this in a transient
114-
$forms = get_posts( array(
115-
'post_per_page' => '-1',
116-
'post_type' => 'wplf-form',
117-
) );
117+
$transient = get_transient("wplf-form-filter");
118+
119+
if($transient){
120+
$forms = $transient;
121+
}
122+
123+
else{
124+
$forms = get_posts( array(
125+
'post_per_page' => '-1',
126+
'post_type' => 'wplf-form',
127+
) );
128+
129+
set_transient("wplf-form-filter", $forms, 15 * MINUTE_IN_SECONDS);
130+
}
131+
118132
?>
119133
<label for="filter-by-form" class="screen-reader-text">Filter by form</label>
120134
<select name="form" id="filter-by-form">
@@ -201,4 +215,3 @@ function metabox_submission() {
201215
}
202216

203217
endif;
204-

0 commit comments

Comments
 (0)