Skip to content

Instantly share code, notes, and snippets.

View SJ-James's full-sized avatar

Stephen James SJ-James

View GitHub Profile
@SJ-James
SJ-James / auto-enable-divi-page-builder-cpt
Last active April 30, 2018 21:28
Auto-enable Divi Page Builder on all public custom post types (WooCommerce, LearnPress etc)
<?php
// copy function into functions.php
function dpb_all_post_types( $post_types ) {
$args = array(
'public' => true,
'_builtin' => true
);
@SJ-James
SJ-James / related-posts.php
Last active January 6, 2018 17:41
Display related posts by category on single-post template...
@SJ-James
SJ-James / facebook_warning.php
Created December 11, 2017 17:47
Facebook Browser Warning | Divi
<?php
if ( !function_exists( 'fb_browser_warning' ) ) {
function fb_browser_warning() {
?>
<style>
.fb_browser_warning {
position: relative;
background: #3B5998;
padding: 20px 20px 20px 80px;
@SJ-James
SJ-James / functions.php
Created January 3, 2018 11:39
Clear Local Storage Button For Divi
<?php
function ClearLocalCacheButton() { ?>
// Create Button
<a href="#" onclick="ClearLocalCache()" class="et-pb-layout-buttons et-pb-layout-buttons-cache" title="Clear Cache">
<span>Clear Cache</span>
</a>
<script type="text/javascript">
// Move Button to Divi Tabs
jQuery(window).load(function(){
@SJ-James
SJ-James / limit-low-stock-woo.php
Created January 4, 2018 19:05
Limit Quantity for low stock items
<?php
function limit_wc_stock() {
global $product;
if ( $product->stock ) {
if ( number_format($product->stock,0,'','') < 100 ) { // If stock is less than 100
/* Limit Quantity */
function limit_wc_stock_quantity_args( $args, $product ) {
$args['max_value'] = 10; // Max value
return $args;
}
@SJ-James
SJ-James / more-divi-social-icons.php
Last active March 27, 2019 13:50 — forked from mrkdevelopment/In your social icons file
Divi social icons extension
<?php // << Remove opener if adding to functions.php
if ( ! function_exists( 'et_load_core_options' ) ) {
function et_load_core_options() {
global $shortname, $themename;
require_once get_template_directory() . esc_attr( "/options_{$shortname}.php" );
$newOptions = [];
foreach ($options as $i => $optionArray) {
@SJ-James
SJ-James / move-social-icons.php
Created March 7, 2018 10:42
Divi Mod - Move Slide In Social Icons Into The Main Header
<?php
// Execute as function or preferably move CSS and jQuery into correct child theme files.
function sj_move_social_icons() { ?>
<script>
jQuery(function($){
// Use jQuery to move the object
$(".et_slide_menu_top .et-social-icons").insertBefore("#et-top-navigation");
});
</script>
@SJ-James
SJ-James / collapse_sections.php
Created March 14, 2018 01:14
Add a 'Collapse Section' button to the Elementor Editor
<?php
//Add to functions.php in child theme
function e_collapse_sections(){
?>
<!-- Scripts and styles should enqueued properly but for the sake of having it all in one function...-->
<script>
if ( self !== top ) { // Check if we're in a preview window / iframe
jQuery(document).ready(function($){
@SJ-James
SJ-James / etModules-icon-codes.css
Created March 21, 2018 21:33
A list of the codes for Divi's built in icon collection
/* example of use */
h1:before {
font-family: 'etModules';
content: "\24";
}
/* codes */
.arrow_up:before {
content: "\21";
function special_divi_header(){?>
<ul id="new-top-menu">
<?php echo wp_nav_menu( array( 'theme_location' => 'secondary-menu' ) ); ?>
</ul>
<script>
jQuery(document).ready(function ($) {
$("<ul id='new-menu'></ul>").insertAfter("#et-top-navigation");
$("#mobile_menu_slide .outside").clone().appendTo("#new-menu");
$("#top-menu").insertBefore("#main-header .container");