Revision: 38599
Updated Code
at January 5, 2011 20:06 by thefrosty
Updated Code
/** * Lets manage the new column * * @ref http://wordpress.org/support/topic/custom-post-type-admin-ui-with-custom-taxonomies * @ref http://wordpress.org/support/topic/add-id-column-to-custom-taxonomy-admin-display-1 * @help http://snipplr.com/view/46538/manage-custom-taxonomy-column-meta/ (??) * @since 0.1.0 */ function manage_venues_column( $tag, $column_name ) { global $wpdb, $taxonomy, $post, $post_type; /* get_metadata( $meta_type, $object_id, $meta_key = '', $single = false ) */ $address = get_metadata( 'venues', get_venues_id_by_key( 'address' ), 'address', true ); $city = get_metadata( 'venues', get_venues_id_by_key( 'city' ), 'city', true ); $state = get_metadata( 'venues', get_venues_id_by_key( 'state' ), 'state', true ); $zip = get_metadata( 'venues', get_venues_id_by_key( 'zip' ), 'zip', true ); $gmaps = 'http://maps.google.com/maps?q='; if ( !empty( $address ) ) $gmaps .= urlencode( $address ); if ( !empty( $city ) ) $gmaps .= '+' . urlencode( $city ); if ( !empty( $state ) ) $gmaps .= ',+' . urlencode( $state ); if ( !empty( $zip ) ) $gmaps .= '+' . urlencode( $zip ); $map_script = "<script type='text/javascript'>jQuery(document).ready( function() { jQuery('th#maps.manage-column.column-maps').css({ textAlign: 'center', width: '10%' }); jQuery('td.maps.column-maps').css({ textAlign: 'center', width: '10%' }); });</script>"; $edit_link = get_edit_term_link( $tag->term_id, $taxonomy, $post_type ); //Not correct, need old query_var_something.... switch( $column_name ) { case 'maps' : if ( !empty( $address ) ) { echo $map_script . '<a href="'.$gmaps.'" target="_blank" style="color:green"><strong>√</strong></a>'; } else { echo $map_script . '<a class="nomap" href="' . $edit_link . '" style="color:red"><strong>χ</strong></a>' . var_dump( get_venues_id_by_key( 'address' ) ); } break; } } /** * Try to get the ID by way of $wpdb * * @ref http://wpseek.com/blog/2010/how-to-get-the-meta-id-by-meta-key/80/ * @since 0.1.0 */ function get_venues_id_by_key( $meta_key ) { global $wpdb; $venue = $wpdb->get_var( $wpdb->prepare( "SELECT venues_id FROM $wpdb->venuesmeta WHERE meta_key = %s", $meta_key ) ); if ( $venue != '' ) return (int)$venue; return false; }
Revision: 38598
Updated Code
at January 5, 2011 17:35 by thefrosty
Updated Code
function manage_venues_column( $tag, $column_name ) { global $wpdb, $taxonomy; $wpdb->venuesmeta = $wpdb->prefix . 'venuesmeta'; if ( empty( $tag ) ) $tag = 'venues'; /* get_metadata( $meta_type, $object_id, $meta_key = '', $single = false ) */ $address = get_metadata( $tag->taxonomy, $tag->term_id, 'address', true ); $city = get_metadata( $tag->taxonomy, $tag->term_id, 'city', true ); $state = get_metadata( $tag->taxonomy, $tag->term_id, 'state', true ); $zip = get_metadata( $tag->taxonomy, $tag->term_id, 'zip', true ); $gmaps = 'http://maps.google.com/maps?q='; if ( !empty( $address ) ) $gmaps .= urlencode( $address ); if ( !empty( $city ) ) $gmaps .= '+' . urlencode( $city ); if ( !empty( $state ) ) $gmaps .= ',+' . urlencode( $state ); if ( !empty( $zip ) ) $gmaps .= '+' . urlencode( $zip ); $map_script = "<script type='text/javascript'>jQuery(document).ready( function() { jQuery('th#maps.manage-column.column-maps').css({ textAlign: 'center', width: '10%' }); jQuery('td.maps.column-maps').css({ textAlign: 'center', width: '10%' }); });</script>"; switch( $column_name ) { case 'maps' : if ( !empty( $address ) ) { echo $map_script . '<a href="'.$gmaps.'" target="_blank" style="color:green"><strong>√</strong></a>'; } else { echo $map_script . '<a class="nomap" href="" style="color:red"><strong>χ</strong></a>'; } break; } }
Revision: 38597
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 5, 2011 17:23 by thefrosty
Initial Code
function manage_venues_column( $tag, $column_name ) { global $wpdb, $taxonomy; $wpdb->venuesmeta = $wpdb->prefix . 'venuesmeta'; /* get_metadata( $meta_type, $object_id, $meta_key = '', $single = false ) */ $address = get_metadata( $tag->taxonomy, $tag->term_id, 'address', true ); $city = get_metadata( $tag->taxonomy, $tag->term_id, 'city', true ); $state = get_metadata( $tag->taxonomy, $tag->term_id, 'state', true ); $zip = get_metadata( $tag->taxonomy, $tag->term_id, 'zip', true ); $gmaps = 'http://maps.google.com/maps?q='; if ( !empty( $address ) ) $gmaps .= urlencode( $address ); if ( !empty( $city ) ) $gmaps .= '+' . urlencode( $city ); if ( !empty( $state ) ) $gmaps .= ',+' . urlencode( $state ); if ( !empty( $zip ) ) $gmaps .= '+' . urlencode( $zip ); $map_script = "<script type='text/javascript'>jQuery(document).ready( function() { jQuery('th#maps.manage-column.column-maps').css({ textAlign: 'center', width: '10%' }); jQuery('td.maps.column-maps').css({ textAlign: 'center', width: '10%' }); });</script>"; switch( $column_name ) { case 'maps' : if ( !empty( $address ) ) { echo $map_script . '<a href="'.$gmaps.'" target="_blank" style="color:green"><strong>√</strong></a>'; } else { echo $map_script . '<a class="nomap" href="" style="color:red"><strong>χ</strong></a>'; } break; } }
Initial URL
Initial Description
It's working now. Just having issue with it applying to all columns. Need to keep checking. (IE. have to tax's for testing, only one has the additional meta info attached, but they are both showing in the column as having the address as "active" (using same addy for both) will play more ).
Initial Title
Manage Custom $taxonomy column meta
Initial Tags
wordpress
Initial Language
PHP