File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
203217endif ;
204-
You can’t perform that action at this time.
0 commit comments