Skip to content

Instantly share code, notes, and snippets.

@tareq1988
Created October 27, 2018 15:15
Show Gist options
  • Save tareq1988/a01e0b64b1e49965600c8d2ceea71b13 to your computer and use it in GitHub Desktop.
Save tareq1988/a01e0b64b1e49965600c8d2ceea71b13 to your computer and use it in GitHub Desktop.
Dokan seller info in popup on store page
<?php
add_action( 'wp_enqueue_scripts', function() {
if ( ! dokan_is_store_page() ) {
return;
}
wp_enqueue_style('dokan-magnific-popup');
wp_enqueue_script('dokan-popup');
} );
add_action( 'dokan_store_header_info_fields', function( $vendor_id ) {
$bio = get_user_meta( $vendor_id, 'description', true );
$more = ' <a href="#" id="vendor-bio-' . $vendor_id . '">(read more..)</a>';
echo '<li>';
echo wp_trim_words( $bio, 3, $more );
echo '</li>';
?>
<script>
jQuery(function($) {
$('#vendor-bio-<?php echo $vendor_id; ?>').magnificPopup({
items: {
src: '<div class="white-popup" style="padding: 20px"><?php echo esc_js( $bio ); ?></div>',
type: 'inline'
}
});
})
</script>
<?php
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment