add_action('init', function(){
function get_funds(){
$all_funds = [];
- $custom_terms = get_terms('fund_group');
- foreach($custom_terms as $custom_term) {
wp_reset_query();
$args = array(
'post_type' => 'fund',
'numberposts' => -1,
- 'tax_query' => array(
- array(
- 'taxonomy' => 'fund_group',
- 'field' => 'slug',
- 'terms' => $custom_term->slug,
- 'hide_empty' => false
- ),
- ),
);
$loop = get_posts($args);
foreach($loop as $l){
- $funds_grouped[$custom_term->name][] = $l->post_title;
$all_funds[]= $l->post_title;
}
- }
- $js_funds_grouped = json_encode($funds_grouped);
$js_all_funds = json_encode($all_funds);
return $js_all_funds;
var amount = 0;
// set up autocomplete
- $('.gfield_list_2_cell2').children().autocomplete({source: tags});
+ // $('.gfield_list_2_cell2').children().autocomplete({source: tags});
- $(document).on('keydown.autocomplete','.gfield_list_2_cell2 > input', function(){
- $(this).autocomplete({source: tags});
- });
+ // $(document).on('keydown.autocomplete','.gfield_list_2_cell2 > input', function(){
+ // $(this).autocomplete({source: tags});
+ // });
+
+ $('.gfield_list_2_cell2 > input').swapSelect();
$(document).on("click", '.delete_list_item', function(e){
var amount = $(this).parent().prev().prev().children('input').val();
}
})
});
+
+ $.fn.swapSelect = function(){
+ var parent = this.parent();
+ parent.css("width", "50%");
+ this.remove();
+ var select = $("<select />",
+ {
+ class: "dropdown-excerpt-background",
+ name: "input_2[]",
+ css:{
+ display: 'none',
+ }
+ }
+
+ );
+
+ select.appendTo(parent);
+ $('<option value="">Select a Fund</option>').appendTo(select);
+ $.each(all_funds, function(){
+ $('<option value="' + this + '">' + this + '</option>').appendTo(select);
+ })
+ this.fadeOut(function(){
+ select.fadeIn();
+ });
+ }
});;// Load foundation
$(document).foundation();
$(document).ready(function () {
var amount = 0;
// set up autocomplete
- $('.gfield_list_2_cell2').children().autocomplete({source: tags});
+ // $('.gfield_list_2_cell2').children().autocomplete({source: tags});
- $(document).on('keydown.autocomplete','.gfield_list_2_cell2 > input', function(){
- $(this).autocomplete({source: tags});
- });
+ // $(document).on('keydown.autocomplete','.gfield_list_2_cell2 > input', function(){
+ // $(this).autocomplete({source: tags});
+ // });
+
+ $('.gfield_list_2_cell2 > input').swapSelect();
$(document).on("click", '.delete_list_item', function(e){
var amount = $(this).parent().prev().prev().children('input').val();
}
})
});
+
+ $.fn.swapSelect = function(){
+ var parent = this.parent();
+ parent.css("width", "50%");
+ this.remove();
+ var select = $("<select />",
+ {
+ class: "dropdown-excerpt-background",
+ name: "input_2[]",
+ css:{
+ display: 'none',
+ }
+ }
+
+ );
+
+ select.appendTo(parent);
+ $('<option value="">Select a Fund</option>').appendTo(select);
+ $.each(all_funds, function(){
+ $('<option value="' + this + '">' + this + '</option>').appendTo(select);
+ })
+ this.fadeOut(function(){
+ select.fadeIn();
+ });
+ }
});
\ No newline at end of file
ob_end_clean();
return $output;
}
-add_action( 'init', 'fund_taxonomies' );
+// add_action( 'init', 'fund_taxonomies' );
add_action( 'init', 'custom_post_type' );
add_shortcode( 'list-funds', 'funds_shortcode' );
/**
}
add_filter( 'parse_query', 'fund_taxonomy_filter_post_type_request' );
-/**
- * Save Meta Data
- *
- * Saves the meta fields for the product
- *
- * @access public
- * @return void
- */
-//function save_meta() {
-// global $post;
-// if ( isset( $_POST['title-meta-noncename'] ) && ! wp_verify_nonce( $_POST['title-meta-noncename'], 'title-meta-noncename' ) ) {
-// return $post->ID;
-// }
-// if ( isset( $post ) && ! current_user_can( 'edit_post', $post->ID ) ) {
-// return $post->ID;
-// }
-// $name = ( isset( $_POST['partner_name'] ) ? filter_var( $_POST['partner_name'] ) : '' );
-// $title = ( isset( $_POST['partner_title'] ) ? filter_var( $_POST['partner_title'] ) : '' );
-// $email = ( isset( $_POST['partner_email'] ) ? filter_var( $_POST['partner_email'] ) : '');
-// $phone = ( isset( $_POST['partner_phone'] ) ? filter_var( $_POST['partner_phone'] ) : '');
-// $url = ( isset( $_POST['partner_url'] ) ? filter_var( $_POST['partner_url'] ) : '');
-//
-// if ( isset( $post ) ) {
-// update_post_meta( $post->ID, 'partner_name', $name );
-// update_post_meta( $post->ID, 'partner_title', $title );
-// update_post_meta( $post->ID, 'partner_email', $email );
-// update_post_meta( $post->ID, 'partner_phone', $phone );
-// update_post_meta( $post->ID, 'partner_url', $url );
-// update_post_meta($post->ID, 'internal_url', $_POST['internal_url']);
-// update_post_meta($post->ID, 'internal_page', $_POST['internal_page']);
-// }
-//}
-
-/**
- * add_metaboxes
- *
- * Add the meta fields
- *
- * @access public
- * @return void
- */
-//function add_metaboxes() {
-// add_meta_box( 'partner_info', 'Partner Information', 'partner_info', GLM_POST_TYPE, 'normal', 'low' );
-//}
-//add_action( 'save_post', 'save_meta' );