Skip to content

Instantly share code, notes, and snippets.

@anthonysbrown
Created December 15, 2020 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anthonysbrown/df5a3d019e4c9ea79506d26730edde8f to your computer and use it in GitHub Desktop.
Save anthonysbrown/df5a3d019e4c9ea79506d26730edde8f to your computer and use it in GitHub Desktop.
divisoup.js
<script>jQuery(document).ready(function($) {
$("img[title]").each(function() { $(this).removeAttr("title"); });
});</script>
<script type="text/javascript">
jQuery(document).ready( function($) {
$(".et_pb_contact_captcha_question").prepend("<span> Please prove your humanity &nbsp;&nbsp;</span>" );
});
</script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery('.et-social-icon a').attr('target','_blank');
});
</script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<script>
//Journal Blog Kit for Divi by Divi Soup
jQuery(document).ready(function ($) {
// console.log('ready');
// console.log('ajax ready');
//Remove pipes, commas and 'by' from the meta
$(".post-meta").html(function () {
return $(this).html().replace(/\|/g, '').replace('by', '').replace(/,/g, '');
});
//Wrap text nodes in a container on archive pages
$(".archive .et_pb_post, .search .et_pb_post").contents().filter(function () {
return this.nodeType === 3;
}).wrap('<p class="post-content"></p>').end();
//Remove all previously created containers except the excerpt
$('.archive .et_pb_post .post-content:not(:last-child)').remove();
$('.search .et_pb_post .post-content:not(:last-child)').remove();
//Wrap the post content in a container
$(".ds-blog .et_pb_post, .archive .et_pb_post, .search .et_pb_post").each(function () {
var find_leng = $(this).find('.entry-title, .post-meta, .post-content');
console.log(find_leng);
$(this).find('.entry-title, .post-meta, .post-content').wrapAll('<div class="ds-blog-content"></div>');
});
//Wrap the category in a container
$(".ds-blog .et_pb_post, .archive .et_pb_post, .search .et_pb_post, .single .et_pb_post").each(function () {
$(this).find('[rel~="tag"]').wrapAll('<div class="ds-blog-cat"></div>');
//Move the vategory above the post title
$(this).find('.ds-blog-cat').detach().insertBefore($(".entry-title", this));
});
//Wrap text nodes in comments container and remove all but last
$(".et_pb_post .post-meta").contents().filter(function () {
return this.nodeType === 3;
}).wrap('<span class="ds-comments"></span>').end();
$('.et_pb_post .post-meta span.ds-comments:not(:last-child)').remove();
//Limit the excerpt length - change the two instances of '115' to the number of characters you want displayed.
$('.ds-blog .et_pb_post .post-content p, .archive .et_pb_post p.post-content, .search .et_pb_post p.post-content').each(function () {
var dsExcerpt = $(this)
, dsExcerptText = dsExcerpt.text()
, chars = dsExcerptText.length;
if (chars > 115) {
var dsExcerptTextNew = dsExcerptText.substring(0, 115) + "...";
dsExcerpt.text(dsExcerptTextNew);
}
});
//Add the Divi button class to the read more link, pagination and edit comment
$('.ds-blog .et_pb_post a.more-link, .pagination a, .single .comment-edit-link').addClass('et_pb_button');
//Remove pagination arrows
$(".ds-blog .pagination a, .archive .pagination a, .search .pagination a").html(function () {
return $(this).html().replace('«', '').replace('»', '');
});
//Add a read more container to archive pages
$('.archive .et_pb_post .ds-blog-content, .search .et_pb_post .ds-blog-content').each(function () {
$('<div class="more-container">read more</div>').insertAfter($(this).find('.post-content'));
});
//Grab the link from the post title and add it inside the read more container to create a read more button on archive pages
$('.archive .et_pb_post .more-container, .search .et_pb_post .more-container').contents().wrap(function () {
return $(this).closest('.et_pb_post').find('.entry-title a').clone().text('').addClass('more-link et_pb_button');
});
//Search widget placeholder text
$('.widget_search input#s').attr('placeholder', 'Enter search terms');
//Change comments title to H4 element
$('.single-post .et_pb_post h1#comments').replaceWith(function () {
return $('<h4 id="comments" />').append($(this).contents());
});
//Change submit comment title to H4 element
$('.single-post .et_pb_post h3#reply-title').replaceWith(function () {
return $('<h4 id="reply-title" />').append($(this).contents());
});
});
//End Journal Blog Kit for Divi by Divi Soup
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment