| @@ -29,8 +29,12 @@ | ||
| 29 | 29 | if( isset( $new ) && $field == 'wpupg_post_types' ) { |
| 30 | 30 | $new = array( $new ); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | + if( isset( $new ) && $field == 'wpupg_taxonomies' ) { | |
| 34 | + $new = array( $new ); | |
| 35 | + } | |
| 36 | + | |
| 33 | 37 | // Update or delete meta data if changed |
| 34 | 38 | if( isset( $new ) && $new != $old ) { |
| 35 | 39 | update_post_meta( $post_id, $field, $new ); |
| 36 | 40 | } elseif ( $new == '' && $old ) { |
| @@ -37,8 +41,21 @@ | ||
| 37 | 41 | delete_post_meta( $post_id, $field, $old ); |
| 38 | 42 | } |
| 39 | 43 | } |
| 40 | 44 | |
| 45 | + // Limit terms | |
| 46 | + if( isset( $_POST['wpupg_limit_terms'] ) && $_POST['wpupg_limit_terms'] ) { | |
| 47 | + $taxonomy = isset( $_POST['wpupg_taxonomies'] ) ? $_POST['wpupg_taxonomies'] : false; | |
| 48 | + | |
| 49 | + if ( $taxonomy ) { | |
| 50 | + $limit_terms_terms = isset( $_POST['wpupg_form_limit_terms_' . $taxonomy . '_terms'] ) ? $_POST['wpupg_form_limit_terms_' . $taxonomy . '_terms'] : array(); | |
| 51 | + $limit_terms_type = isset( $_POST['wpupg_form_limit_terms_' . $taxonomy . '_type'] ) ? $_POST['wpupg_form_limit_terms_' . $taxonomy . '_type'] : 'restrict'; | |
| 52 | + | |
| 53 | + update_post_meta( $post_id, 'wpupg_limit_terms_terms', $limit_terms_terms ); | |
| 54 | + update_post_meta( $post_id, 'wpupg_limit_terms_type', $limit_terms_type ); | |
| 55 | + } | |
| 56 | + } | |
| 57 | + | |
| 41 | 58 | // Limit rules |
| 42 | 59 | |
| 43 | 60 | $limit_rules = array(); |
| 44 | 61 | |
| @@ -73,10 +90,33 @@ | ||
| 73 | 90 | // Filter Taxonomies |
| 74 | 91 | $post_type = $_POST['wpupg_post_types']; |
| 75 | 92 | |
| 76 | 93 | if( isset( $_POST['wpupg_filter_taxonomy_' . $post_type] ) ) { |
| 77 | - update_post_meta( $post_id, 'wpupg_filter_taxonomies', $_POST['wpupg_filter_taxonomy_' . $post_type] ); | |
| 94 | + $filter_taxonomies = $_POST['wpupg_filter_taxonomy_' . $post_type]; | |
| 95 | + update_post_meta( $post_id, 'wpupg_filter_taxonomies', $filter_taxonomies ); | |
| 78 | 96 | } |
| 97 | + | |
| 98 | + // Filter Limit Terms | |
| 99 | + $filter_limit_terms = array(); | |
| 100 | + if( isset( $filter_taxonomies ) ) { | |
| 101 | + foreach( $filter_taxonomies as $filter_taxonomy ) { | |
| 102 | + if( isset( $_POST['wpupg_filter_limit_terms_' . $filter_taxonomy] ) ) { | |
| 103 | + $filter_limit_terms[$filter_taxonomy] = $_POST['wpupg_filter_limit_terms_' . $filter_taxonomy]; | |
| 104 | + } | |
| 105 | + } | |
| 106 | + } | |
| 107 | + update_post_meta( $post_id, 'wpupg_filter_limit_terms', $filter_limit_terms ); | |
| 108 | + | |
| 109 | + // Filter Dropdown Labels | |
| 110 | + $filter_dropdown_labels = array(); | |
| 111 | + if( isset( $filter_taxonomies ) ) { | |
| 112 | + foreach( $filter_taxonomies as $filter_taxonomy ) { | |
| 113 | + if( isset( $_POST['wpupg_filter_dropdown_label_' . $filter_taxonomy] ) ) { | |
| 114 | + $filter_dropdown_labels[$filter_taxonomy] = $_POST['wpupg_filter_dropdown_label_' . $filter_taxonomy]; | |
| 115 | + } | |
| 116 | + } | |
| 117 | + } | |
| 118 | + update_post_meta( $post_id, 'wpupg_filter_dropdown_labels', $filter_dropdown_labels ); | |
| 79 | 119 | |
| 80 | 120 | // Filter style metadata |
| 81 | 121 | $styles = $grid->filter_style_fields(); |
| 82 | 122 | $filter_style = array(); |