Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@amsgator
amsgator / remove_select2.php
Created April 5, 2019 22:42
Remove Select2 / SelectWoo from WooCommerce
<?php
function dequeue_select2() {
if ( class_exists( 'woocommerce' ) ) {
// Styles
wp_dequeue_style( 'select2' );
wp_deregister_style( 'select2' );
// Scripts
wp_dequeue_script( 'selectWoo' );
wp_deregister_script( 'selectWoo' );
@amsgator
amsgator / dequeue_woo.php
Created April 6, 2019 00:28
Dequeue WooCommerce Scripts from Non-WooCommerce Pages / Posts
<?php
function dequeue_woo() {
if ( function_exists( 'is_woocommerce' ) ) {
if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() && ! is_account_page() ) {
// Styles
wp_dequeue_style( 'woocommerce-general' );
wp_dequeue_style( 'woocommerce-layout' );
wp_dequeue_style( 'woocommerce-smallscreen' );
// Scripts
@amsgator
amsgator / redirect_attachment_urls.php
Created April 7, 2019 23:35
Redirect Attachment URLs to the Attachment Itself
<?php
function redirect_attachment_urls() {
if ( is_attachment() ) {
wp_redirect( wp_get_attachment_url(), 301 );
exit();
}
}
add_action( 'template_redirect', 'redirect_attachment_urls' );
@amsgator
amsgator / border-box-fix.css
Created April 21, 2019 20:16
Border-box fix
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
@amsgator
amsgator / .htaccess
Created June 24, 2019 19:50
Redirect all traffic to https www in 1 hop
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect all naked http(s) to https www in 1 hop
RewriteCond %{HTTP_HOST} ^domain\.com [NC]
RewriteRule ^(.*)$ https://www\.domain\.com/$1 [R=301,L]
# Redirect all http www to https www in 1 hop
RewriteCond %{HTTPS} !on [NC]
RewriteRule ^(.*)$ https://www\.domain\.com/$1 [R=301,L]
@amsgator
amsgator / .htaccess
Created June 24, 2019 23:21
Redirect all traffic to naked https in 1 hop
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect all http to naked https in 1 hop
RewriteCond %{HTTPS} !on [NC]
RewriteRule ^(.*)$ https://domain\.com/$1 [R=301,L]
# Redirect all https www to naked https in 1 hop
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule ^(.*)$ https://domain\.com/$1 [R=301,L]
@amsgator
amsgator / disable_gutenberg.php
Created July 7, 2019 21:02
Completely Disable Gutenberg Block Editor
<?php
add_filter('use_block_editor_for_post', '__return_false', 10);
?>
@amsgator
amsgator / vcard.php
Created July 9, 2019 20:13
Enable vCard Upload in WordPress
<?php
function enable_vcard_upload( $mime_types ){
$mime_types['vcf'] = 'text/vcard';
$mime_types['vcard'] = 'text/vcard';
return $mime_types;
}
add_filter('upload_mimes', 'enable_vcard_upload' );
?>
@amsgator
amsgator / stop-noreferrer.php
Created September 7, 2019 20:44
Stop WordPress from Adding "noreferrer" to Links
<?php
function my_targeted_link_rel( $rel_values ) {
return 'noopener';
}
add_filter( 'wp_targeted_link_rel', 'my_targeted_link_rel', 999 );
?>