Created
September 18, 2019 18:03
-
-
Save carmoreira/bdbecf1db6a5df894c6b2c666b4d50b0 to your computer and use it in GitHub Desktop.
add cpt to available cpt options in advisor quiz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Create Arrays to populate Query Builder with all available post types | |
| add_filter( 'advq_admin_build_quiz', 'advq_coupon_cpt' ); | |
| function advq_coupon_cpt( $queryfields ) { | |
| $fields = array(); | |
| $fields['label'] = 'Coupon'; | |
| // search | |
| $fields['search'] = array( | |
| 'search-by' => array( | |
| 'label' => __( 'Search Keyword', 'advq' ), | |
| ), | |
| ); | |
| // IDs array | |
| $fields['post__in'] = array( | |
| 'post__in' => array( | |
| 'label' => __( 'IDs', 'advq' ), | |
| ), | |
| ); | |
| // build taxonomy options | |
| $taxonomies = get_object_taxonomies( 'shop_coupon', 'object' ); | |
| foreach ( $taxonomies as $tax ) { | |
| if ( $tax->public == 1 ) { | |
| $opts = array(); | |
| $terms = get_terms( | |
| array( | |
| 'taxonomy' => $tax->name, | |
| 'hide_empty' => false, | |
| ) | |
| ); | |
| foreach ( $terms as $key => $value ) { | |
| $opts[ $value->term_id ] = $value->name; | |
| } | |
| $fields['taxonomy'][ $tax->name ]['label'] = $tax->label; | |
| $fields['taxonomy'][ $tax->name ]['options'] = $opts; | |
| } | |
| } | |
| $queryfields[ 'shop_coupon' ] = $fields; | |
| return $queryfields; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment