Skip to content

Instantly share code, notes, and snippets.

@lukecav
Forked from tareq1988/functions.php
Created October 29, 2018 14:00
Show Gist options
  • Save lukecav/f8d414820346f6d07627a01efe4ec45d to your computer and use it in GitHub Desktop.
Save lukecav/f8d414820346f6d07627a01efe4ec45d to your computer and use it in GitHub Desktop.
Dokan seller info in popup on the 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