Skip to content

Instantly share code, notes, and snippets.

View dmhendricks's full-sized avatar

Daniel M. Hendricks dmhendricks

View GitHub Profile
@dmhendricks
dmhendricks / wordpress-remove-script-versions-functions.php
Last active April 8, 2018 21:45
Remove script versions from enqueued scripts. #wordpress
<?php
/**
* Remove script versions from frontend static scripts.
* Place this code in your child theme's functions.php OR use the plugin below.
*/
add_filter( 'style_loader_src', 'myprefix_remove_script_versions', 9999 );
add_filter( 'script_loader_src', 'myprefix_remove_script_versions', 9999 );
function myprefix_remove_script_versions( $src ) {
@dmhendricks
dmhendricks / jquery.fn.replaceClass.js
Last active May 13, 2018 20:30
jQuery function to replace one or more CSS classes with others.
/**
* jQuery function to replace one or more CSS classes with others. Separate multiple
* classes with spaces.
* @param {string} remove - CSS classes to remove.
* @param {string} add - CSS classes to add.
* @example
* $( '.selector' ).replaceClass( 'old-class', 'new-class some-other-class' );
* $( '.selector' ).replaceClass( 'old-class another-class', 'new-class' );
*/
!function(s){s.fn.replaceClass=function(remove,add){var e=add||remove;return e&&this.removeClass(add?remove:this.className).addClass(e),this}}(jQuery);
@dmhendricks
dmhendricks / wordpress-remove-try-gutenberg-callout-functions.php
Last active September 16, 2018 06:46
Remove the "Try Gutenberg" callout that was added to the dashboard in WordPress 4.9.8
<?php
/**
* Add the following to your child theme's functions.php file to remove
* the "Try Gutenberg" callout introduced in WordPress 4.9.8
*/
remove_filter( 'try_gutenberg_panel', 'wp_try_gutenberg_panel' );
@dmhendricks
dmhendricks / wordpress-tick-remember-me-checkbox-functions.php
Created September 16, 2018 06:46
A hack to automatically tick "Remember Me" checkbox at WordPress login to save support headaches
<?php
/**
* Add the following to your child theme's functions.php file to remove
* automatically tick the "Remember Me" checkbox at WordPress login.
*/
add_action( 'init', function() {
add_filter( 'login_footer', function() {
echo "<script>document.getElementById('rememberme').checked = true;</script>";
});
});
@dmhendricks
dmhendricks / wordpress-remove-gdpr-menu-items-tools-functions.php
Created September 16, 2018 06:53
Remove the "Export Personal Data" and "Erase Personal Data" items from WP Admin > Tools in WordPress
<?php
/**
* Add the following to your child theme's functions.php file to remove the
* "Export Personal Data" and "Erase Personal Data" items from WP Admin > Tools
*/
add_action( 'admin_menu', function() {
remove_submenu_page( 'tools.php', 'remove_personal_data' );
remove_submenu_page( 'tools.php', 'export_personal_data' );
}, 999 );
@dmhendricks
dmhendricks / .gitignore-wpmudev-hosting
Last active November 29, 2018 06:43
A boilerplate .gitignore for WPMU Dev hosting. https://premium.wpmudev.org/multisite-hosting/
# Boilerplate .gitignore for WPMU Dev Hosting. Copy this to .gitignore in your web root.
# Forked from: https://wpengine.com/wp-content/uploads/2013/10/recommended-gitignore-no-wp.txt
# Maintainer: Daniel M. Hendricks (https://daniel.hn)
# Version: 1.0.4
*~
.DS_Store
.env
.svn
.cvs
*.bak
@dmhendricks
dmhendricks / remove-wordpress-generator-page-rss-head-functions.php
Last active December 18, 2018 21:31
Remove the meta generator tag from WordPress page head and RSS feeds
<?php
/* Add this to your child theme's functions.php to remove the generator meta tag from both
* your web sites page head and from your RSS feeds (ex: /feed/)
*/
// Remove generator meta tag from page head
remove_action( 'wp_head', 'wp_generator' );
// Remove generator tag from RSS feeds
add_filter( 'the_generator', '__return_null' );
@dmhendricks
dmhendricks / plesk-wordpress-additional-nginx-directives.conf
Created December 14, 2018 19:37
Plesk Additional nginx Directives
# Plesk Onyx - Additional nginx Directives
# Version 1.0.0
# Maintainer: Daniel M. Hendricks (https://www.danhendricks.com)
# Domains > example.com > Apache & nginx Settings > Additional nginx directives
# Disable directory indexing
autoindex off;
# Enable HSTS (optional)
add_header Strict-Transport-Security "max-age=31536000" always;
@dmhendricks
dmhendricks / wordpress-display-php-version-admin-footer-functions.php
Last active December 15, 2018 17:58
Display PHP Version in WordPress Admin Footer
@dmhendricks
dmhendricks / bash-scripts.md
Last active January 6, 2019 20:28
BASH Scripts

BASH Scripts

List Top 10 Largest Files in Current Directory

./large-files.sh 10