Last active
October 26, 2017 18:52
-
-
Save Garconis/4a814c02f5d73bedb66ed009abf04131 to your computer and use it in GitHub Desktop.
Divi | Automatically wrap the blurb module with its link if it has one by using custom class
This file contains 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
// if blurb has blurb-click class on the module, then move the module link so it wraps the entire blurb | |
jQuery(function($){ | |
// If a Divi Blurb module has a link around the blurb image or the blurb title, then move the link so it wraps the entire blurb | |
$('.et_pb_blurb.blurb-click').each(function() { | |
var blurb_content = $('.et_pb_blurb_content', this); | |
var blurb_image_link = $('.et_pb_blurb_content .et_pb_main_blurb_image a', this); | |
var blurb_title_link = $('.et_pb_blurb_content .et_pb_blurb_container .et_pb_module_header a', this); | |
// if blurb has an image link and a title link, unwrap both links, and then wrap the image link around the entire content | |
if ( $(blurb_image_link).length && $(blurb_title_link).length ) { | |
blurb_image_link.contents().unwrap(); | |
blurb_title_link.contents().unwrap(); | |
blurb_content.wrap(blurb_image_link); | |
} | |
// otherwise, if blurb has only an image link, unwrap it, and then wrap it around the entire content | |
else if ( $(blurb_image_link).length ) { | |
blurb_image_link.contents().unwrap(); | |
blurb_content.wrap(blurb_image_link); | |
} | |
// otherwise, if blurb has only a title link, unwrap it, and then wrap it around the entire content | |
else if ( $(blurb_title_link).length ) { | |
blurb_title_link.contents().unwrap(); | |
blurb_content.wrap(blurb_title_link); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment