Last active
November 5, 2021 01:40
-
-
Save MaruscaGabriel/c6bc83206f8ac970dbfb80d27f2e643c to your computer and use it in GitHub Desktop.
WordPress (DIVI) code snippets
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
<?php | |
// Limit the number of revisions to 3 | |
add_filter( 'wp_revisions_to_keep', 'divi_limit_revisions', 10, 2 ); | |
function divi_limit_revisions( $num ) { | |
$num = 3; | |
return $num; | |
} | |
//Disable Emoji | |
remove_action('wp_head', 'print_emoji_detection_script', 7); | |
remove_action('wp_print_styles', 'print_emoji_styles'); | |
//Stop Heartbeat completely | |
add_action( 'init', 'stop_heartbeat', 1 ); | |
function stop_heartbeat() { | |
wp_deregister_script('heartbeat'); | |
} | |
/*enable pich zooming on mobile devices*/ | |
function definitely_allow_mobile_zooming() { | |
print '<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1.0, minimum-scale=0.1, maximum-scale=10.0">'; | |
print "\n"; | |
} | |
add_action( 'wp_head', 'definitely_allow_mobile_zooming', 9999999 ); | |
//Set the Divi builder as active by default on all pages and posts | |
add_filter( 'et_builder_always_enabled', '__return_true' ); | |
//Change the ‘Projects’ slug to something else: | |
//Add this to your child theme functions.php file, then go into permalinks and hit save (change the word ‘project’ to your desired word): | |
function custom_post_name () { | |
return array( | |
'feeds' => true, | |
'slug' => 'project', | |
'with_front' => false, | |
); | |
} | |
add_filter( 'et_project_posttype_rewrite_args', 'custom_post_name' ); | |
//Auto-enable Divi Page Builder on all public custom post types (WooCommerce, LearnPress etc) | |
function dpb_all_post_types( $post_types ) { | |
$args = array( | |
'public' => true, | |
'_builtin' => false | |
); | |
$output = 'names'; | |
$post_types = get_post_types( $args, $output ); | |
if ( $post_types ) { // If custom post types are present | |
foreach ( $post_types as $post_type ) { | |
$post_types[] ='$post_type'; | |
return $post_types; | |
} | |
} | |
} | |
add_filter( 'et_builder_post_types', 'dpb_all_post_types' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment