Skip to content

Instantly share code, notes, and snippets.

View themightymo's full-sized avatar

Toby Cryns themightymo

View GitHub Profile
@themightymo
themightymo / gist:685840991c9efae371a5ecbbf9a4aa80
Created October 21, 2024 21:52
Enable HSTS via WordPress functions.php
/**
* Enables the HTTP Strict Transport Security (HSTS) header in WordPress.
* Includes preloading with subdomain support.
* via https://thomasgriffin.com/enable-http-strict-transport-security-hsts-wordpress/
*/
function tg_enable_strict_transport_security_hsts_header_wordpress() {
header( 'Strict-Transport-Security: max-age=31536000; includeSubDomains; preload' );
}
add_action( 'send_headers', 'tg_enable_strict_transport_security_hsts_header_wordpress' );
@themightymo
themightymo / gist:d84dde6df9a5449205305f90dd082b0d
Created September 25, 2024 15:59
Show more Google Analytics accounts in the Beehive Pro plugin's dropdown
// Show more accounts in the Beehive Pro plugin
add_filter( 'beehive_google_analytics_ga4_accounts_page_size', function ( $limit ) {
// Increase the limit to 50
return 100;
} );
@themightymo
themightymo / gist:2ca44c853fb4027505bc899e0df36178
Created September 25, 2024 15:58
Hide the WPMUDEV account screen from all users except "themightymo" and "toby"
// Hide The Mighty Mo!'s Google Analytics account info from the Beehive Pro plugin
function restrict_admin_page_access() {
// Get current user's info
$current_user = wp_get_current_user();
// Get the URL to restrict
$restricted_url = 'admin.php?page=beehive-google-analytics#/account';
// Get current URL
@themightymo
themightymo / .htaccess
Created January 25, 2023 18:49
Default Siteground WordPress .htaccess
# SGS XMLRPC Disable Service
<Files xmlrpc.php>
order deny,allow
deny from all
</Files>
# SGS XMLRPC Disable Service END
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
@themightymo
themightymo / redirect_wp_uploads_to_s3
Last active October 23, 2020 17:13
Redirect WordPress "uploads" folder to S3 bucket via .htaccess
# BEGIN Utilize S3 bucket rather than localhost for "uploads" folder - Via https://tinyurl.com/s3redirect
RewriteRule ^wp-content/uploads/(.*)$ https://your_bucket_name.s3.amazonaws.com/wp-content/uploads/$1 [R,L]
# END Utilize S3 bucket
@themightymo
themightymo / gist:45cddd09c9fdbddba54c55acb38477a1
Created October 20, 2020 14:10
Remove/Disable WordPress Featured Images/Thumbnails in functions.php or plugin
/*
Disable auto-generated thumbnails. Via
- https://wordpress.stackexchange.com/questions/91166/how-to-disable-wordpress-from-creating-thumbnails
- https://wordpress.stackexchange.com/questions/260609/remove-image-size-doesnt-seem-to-be-working
*/
function add_image_insert_override($sizes){
unset( $sizes['thumbnail']);
unset( $sizes['medium']);
return $sizes;
}
@themightymo
themightymo / gist:ccfdf28cc614e9822bb4e695b17eb3db
Created June 22, 2020 14:13
Sequel Pro: How to update WordPress Password using md5 hash
/**
* https://fewerthanthree.com/code-snippets/updating-user-password-mysql
*/
UPDATE wp_users
SET user_pass= MD5('password')
WHERE ID = 1
@themightymo
themightymo / Style Gravity Forms with Labels in the Fields
Last active April 20, 2020 19:30
Style Gravity Forms with Labels in the Fields
/*
* BEGIN style Gravity Forms placeholder text
*/
.gform_wrapper .gfield_radio li label {
max-width: 100%;
}
.gfield input::-webkit-input-placeholder,
.gfield textarea::-webkit-input-placeholder,
.gfield select::-webkit-input-placeholder {
/* Chrome/Opera/Safari */
@themightymo
themightymo / .gitignore NEW
Last active January 18, 2023 23:40 — forked from jjeaton/.gitignore
WordPress root .gitignore. Ignore everything and then opt-in (exclude from the ignore) for your custom code.
# codekit #
###########
.sass-cache/
.codekit-config.json
.config.codekit
# wpengine #
############
*~
@themightymo
themightymo / recommended-gitignore-wp
Last active August 2, 2016 21:43
Recommended .gitignore file for WP Engine