以下脚本编译广告客户字段“cp_street”、“cp_city”和“cp_state”,以创建调用我网站上侧边栏地图的地址。我创建了一个名为“cp_address”的新字段,用户可以在其中输入完整地址。如何更改下面的脚本以使两者都起作用?
<?php
// check to see if ad is legacy or not and then assemble the map address
if ( get_post_meta($post->ID, 'location', true) )
$make_address = get_post_meta($post->ID, 'location', true);
else
$make_address = get_post_meta($post->ID, 'cp_street', true) . ' ' . get_post_meta($post->ID, 'cp_city', true) . ' ' . get_post_meta($post->ID, 'cp_state', true) . ' ' . get_post_meta($post->ID, 'cp_zipcode', true);
$coordinates = cp_get_geocode( $post->ID );
?>
<script type="text/javascript">var address = "<?php echo esc_js($make_address); ?>";</script>
<?php cp_google_maps_js($coordinates); ?>