Created
October 16, 2019 22:13
-
-
Save tradesouthwest/0932d35f0056d151f90d29f046421af2 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Prevent direct access to the file. | |
* @subpackage vendors_tmplt/inc/vendors-tmplt-archive-content | |
* @since 1.0 | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
/** | |
* woocommerce_VendorCustomer_meta_fields | |
*/ | |
add_action( 'woocommerce_before_shop_loop', 'vendors_tmplt_before_main_content', 20 ); | |
if( !function_exists('vendors_tmplt_before_main_content') ) : | |
function vendors_tmplt_before_main_content() | |
{ | |
global $wp_query, $post; | |
$term = $wp_query->queried_object; | |
if ( ! is_object( $term ) || empty( $term->term_id ) ) { | |
return; | |
} | |
if( is_product_taxonomy('wcpv_product_vendors') ) { | |
$vendorx_id = $vendor_facebook = $vendor_twitter = $vendor_instagram = | |
$vendor_phone = $vendor_email = $address1 = ''; | |
$vendor = WC_Product_Vendors_Utils::get_vendor_data_by_id( $term->term_id ); | |
$vendor_facebook = get_term_meta( $term->term_id, 'vndtpl_facebook', true ); | |
$vendor_twitter = get_term_meta( $term->term_id, 'vndtpl_twitter', true ); | |
$vendor_instagram = get_term_meta( $term->term_id, 'vndtpl_instagram', true ); | |
$vendor_phone = get_term_meta( $term->term_id, 'vendors_tmplt_phone', true ); | |
$vendor_email = get_term_meta( $term->term_id, 'vendors_tmplt_email', true ); | |
$address1 = get_term_meta( $term->term_id, 'vendors_tmplt_public_address', true ); | |
$vndrstpl_text_one = ( empty( get_option('vendors_tmplt_options')['vendors_tmplt_text_one'] )) | |
? false : get_option('vendors_tmplt_options')['vendors_tmplt_text_one']; | |
$vndrstpl_text_two = ( empty( get_option('vendors_tmplt_options')['vendors_tmplt_text_two'] )) | |
? false : get_option('vendors_tmplt_options')['vendors_tmplt_text_two']; | |
$vndrstpl_text_thr = ( empty( get_option('vendors_tmplt_options')['vendors_tmplt_text_thr'] )) | |
? '' : get_option('vendors_tmplt_options')['vendors_tmplt_text_thr']; | |
ob_start(); | |
echo '<div class="wcpv-vendor-profile-extended"> | |
<section class="vendors-tmplt-container"> | |
<article class="vendors-tmplt-onehalf"> | |
<div class="vendors-tmplt-inner"> | |
<h4>' . esc_html( $vndrstpl_text_one ) . ' ' .$vendorx_id . '</h4> | |
<address> | |
<b>Address: </b>'. esc_html( $address1 ) . '<br /> | |
<b>Phone: </b>' . esc_html( $vendor_phone ) . '<br /> | |
<b>eMail: </b><a href="mailto:' . esc_attr( $vendor_email ) . '" title="' . esc_attr( $vendor_email ) . '">' . esc_attr( $vendor_email ) . '</a></address> | |
<div class="vendors-tmplt-map-container" style=""> | |
<div id="vndrsMap" style="height:100%"></div> | |
</div> | |
</div> | |
</article> | |
<article class="vendors-tmplt-twohalf"> | |
<div class="vendors-tmplt-inner"> | |
<h4>' . esc_html( $vndrstpl_text_two ) . '</h4> | |
<h3>About ' . esc_html( $vendor['name'] ) . '</h3> | |
<p>' . wp_kses_post( $vendor['profile'] ) . '</p> | |
<div id="VndTplHeight"> | |
<ul class="unstyled-inline">'; | |
if( ''!= $vendor_facebook ) { | |
echo '<li class="vt-fb"><a href="'. esc_url($vendor_facebook) .'" title="'. esc_url($vendor_facebook) .'" target="_blank"><i class="fa fa-facebook"></i></a></li>'; | |
} if( ''!= $vendor_twitter ) { | |
echo '<li class="vt-tw"><a href="'. esc_url($vendor_twitter) .'" title="'. esc_url($vendor_twitter) .'" target="_blank"><i class="fa fa-twitter"></i></a></li>'; | |
} if( ''!= $vendor_instagram ) { | |
echo '<li class="vt-tw"><a href="'. esc_url($vendor_instagram) .'" title="'. esc_url($vendor_instagram) .'" target="_blank"><i class="fa fa-instagram"></i></a></li>'; | |
} | |
echo '</ul> | |
</div> | |
</div> | |
</article> | |
</section> | |
<script src="'. esc_url( "https://maps.googleapis.com/maps/api/js?key=$vndrstpl_text_thr" ) .'"></script> | |
<script id="vndrstplMap" type="text/javascript"> | |
var address = "'. esc_attr($address1) .'"; | |
var map = new google.maps.Map(document.getElementById("vndrsMap"), { | |
mapTypeId: google.maps.MapTypeId.TERRAIN, | |
zoom: 15 | |
}); | |
var geocoder = new google.maps.Geocoder(); | |
geocoder.geocode({ | |
"address": address | |
}, | |
function(results, status) { | |
if(status == google.maps.GeocoderStatus.OK) { | |
new google.maps.Marker({ | |
position: results[0].geometry.location, | |
map: map | |
}); | |
map.setCenter(results[0].geometry.location); | |
} | |
});</script> | |
</div> | |
<div class="clearfix"></div> | |
<div class="vendors_tmplt-below-vendors-tmplt">'; | |
echo WC_Product_Vendors_Utils::get_vendor_rating_html( $term->term_id ); | |
echo '</div>'; | |
$html = ob_get_clean(); | |
echo $html; | |
} | |
} | |
endif; | |
function vendors_tmplt_display_vendor_rating_below() | |
{ | |
$term = $wp_query->queried_object; | |
if ( ! is_object( $term ) || empty( $term->term_id ) ) { | |
return; | |
} | |
if ( is_tax( WC_PRODUCT_VENDORS_TAXONOMY, $term->term_id ) ) { | |
$vendor_data = get_term_meta( $term->term_id, 'vendor_data', true ); | |
//$show_ratings = get_option( 'wcpv_vendor_settings_vendor_review', 'yes' ); | |
$ratings = WC_Product_Vendors_Utils::get_vendor_rating_html( $term->term_id ); | |
return $rating; | |
} else { return '';} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment