Skip to content

Instantly share code, notes, and snippets.

@joshhartman
joshhartman / functions.php
Last active Jul 5, 2022
Disable specific WordPress shortcodes when editing with Beaver Builder
View functions.php
<?php
// Disable specific WordPress shortcodes when editing with Beaver Builder
function shortcode_compatibility_bb_fix() {
if ( FLBuilderModel::is_builder_active() ) {
remove_shortcode( 'gravityform' );
remove_shortcode( 'fl_builder_insert_layout' );
}
}
add_action( 'wp', 'shortcode_compatibility_bb_fix' );
@joshhartman
joshhartman / functions.php
Created Dec 14, 2021
Add a Custom WordPress Image Size and Register for Use with UABB and Other Plugins
View functions.php
<?php
// Add new image size for mini gallery
add_action( 'after_setup_theme', 'custom_theme_setup' );
function custom_theme_setup(){
add_image_size( 'mini-thumb', 75, 75, array( 'center', 'center' ) );
}
// Register image size for plugins to use
add_filter( 'image_size_names_choose', 'custom_image_sizes' );
add_filter( 'uabb_photo_gallery_image_sizes', 'custom_image_sizes' );
@joshhartman
joshhartman / gzip_mime_types.txt
Created Oct 11, 2021
GZIP MIME Types List for use with cPanel's "Optimize Website" Module
View gzip_mime_types.txt
Navigate to cPanel > Optimize Website.
Choose "Compress the specified MIME types."
Clear the contents of the "Mime Types" text input field and paste in the following space-separated list of MIME types:
text/css text/html text/javascript text/plain text/xml application/javascript application/rss+xml application/vnd.ms-fontobject application/x-font application/x-font-opentype application/x-font-otf application/x-font-truetype application/x-font-ttf application/x-javascript application/xhtml+xml application/xml font/opentype font/otf font/ttf image/svg+xml image/x-icon
Click "Update Settings" button to save your changes.
@joshhartman
joshhartman / functions.php
Created Oct 2, 2021
Defer Loading CSS in WordPress to Prevent Render-Blocking
View functions.php
<?php
// Defer Loading CSS in WordPress to Prevent Render-Blocking
function custom_defer_css( $tag, $handle ) {
$css_to_defer = array( 'style-handle-one', 'style-handle-two' );
if ( in_array( $handle, $css_to_defer ) ) {
return str_replace( "media='all'", "media='print' onload=\"this.media='all';\"", $tag );
}
return $tag;
@joshhartman
joshhartman / sysinfo.php
Last active Jan 7, 2022
cPanel Linux Server System Info Summary
View sysinfo.php
<?php
function sys_uptime(){
$uptime = '';
if(is_readable('/proc/uptime')){
$str = @file_get_contents('/proc/uptime');
$num = floatval($str);
$secs = $num % 60;
$num = (int)($num / 60);
$mins = $num % 60;
@joshhartman
joshhartman / gist:fce56971dcac1438f56b14ea9f8ac4d9
Created Jan 11, 2021
Windows Icon Resource EXE/DLLs for use with shortcuts, etc.
View gist:fce56971dcac1438f56b14ea9f8ac4d9
C:\Windows\Explorer.Exe
C:\Windows\System32\AccessibilityCpl.Dll
C:\Windows\System32\compstui.dll
C:\Windows\System32\Ddores.Dll
C:\Windows\System32\DDORes.dll
C:\Windows\System32\GameUx.Dll
C:\Windows\System32\imageres.dll
C:\Windows\System32\mmcndmgr.dll
C:\Windows\System32\mmRes.Dll
C:\Windows\System32\MorIcons.Dll
@joshhartman
joshhartman / functions.php
Created Aug 13, 2020
Override FreeSSL WordPress plugin domain exclusion list
View functions.php
<?php
// Override FreeSSL plugin domain exclusion list
add_filter('option_exclude_domains_auto_install_free_ssl', function ($data) {
$custom_data = array('domains_to_exclude' => array('mail.mydomain.com'));
if(isset($data['domains_to_exclude'])){
$data['domains_to_exclude'] = array_merge($data['domains_to_exclude'], $custom_data['domains_to_exclude']);
return $data;
}
return $custom_data;
});
@joshhartman
joshhartman / functions.php
Last active Aug 3, 2020
Disable specific WordPress shortcodes when editing with Beaver Builder
View functions.php
<?php
function shortcode_compatibility_bb_fix() {
if ( FLBuilderModel::is_builder_active() ) {
remove_shortcode( 'team-members' );
}
}
add_action( 'wp', 'shortcode_compatibility_bb_fix' );
@joshhartman
joshhartman / functions.php
Created Mar 13, 2020
WordPress Admin Login Custom Styling
View functions.php
<?php
function my_custom_login_styles() { ?>
<style type="text/css">
body.login {
background-color: #114892 !important;
}
body.login div#login h1 a {
background-image: url(<?php echo get_stylesheet_directory_uri() ?>/images/site-login-logo.png);
padding-bottom: 15px;
@joshhartman
joshhartman / gist:68bb189fc13ed604a73eb5a7a3d9cb68
Created Mar 5, 2020
ImageMagick -- Resize large images recursively and preserve the aspect ratio -- Windows Command Prompt
View gist:68bb189fc13ed604a73eb5a7a3d9cb68
FOR /R %f IN (*.jpg) DO magick "%f" -resize 3000x3000^> -quality 85 "%f"