Skip to content

Instantly share code, notes, and snippets.

View mitchellkrogza's full-sized avatar
🤓
Busy ... Always busy

Mitchell Krog mitchellkrogza

🤓
Busy ... Always busy
View GitHub Profile
@mitchellkrogza
mitchellkrogza / disable-wp-json
Last active July 3, 2021 13:36
Disable wp-json User Endpoints for Wordpress
// Set this function to only run on front end ONLY (NOT in Admin side it breaks things)
// Use Code Snippets Plugin set to Front end only
add_filter( 'rest_user_query', '__return_null' );
add_filter( 'rest_prepare_user', '__return_null' );
@mitchellkrogza
mitchellkrogza / inline-flatsome.css
Last active June 23, 2021 06:57
Inline flatsome.css (Flatsome Theme)
// This function can be adapted and modified to inline any theme or plugin CSS you like
// Inlining any critical CSS can make big improvements on your site speed
// Dont get carried away inlining everything - Keep it to critical and essential CSS
add_action('wp_head', 'inject_flatsome', 5);
function inject_flatsome() {
ob_start();
include 'wp-content/themes/flatsome/assets/css/flatsome.css';
$atf_css = ob_get_clean();
if ($atf_css != "" ) {
echo '<style id="inline-css" type="text/css">'. $atf_css . '</style>';
@mitchellkrogza
mitchellkrogza / bypass-woocommerce-logout-confirmation
Last active June 6, 2021 14:05
Bypass Woocommerce Logout Confirmation
function flatsome_bypass_logout_confirmation() {
global $wp;
if ( isset( $wp->query_vars['customer-logout'] ) ) {
wp_redirect( str_replace( '&amp;', '&', wp_logout_url( wc_get_page_permalink( 'myaccount' ) ) ) );
exit;
}
}
add_action( 'template_redirect', 'flatsome_bypass_logout_confirmation' );
@mitchellkrogza
mitchellkrogza / disable-wp-sitemaps
Created June 6, 2021 14:04
Disable Wordpress 5 sitemaps
add_filter( 'wp_sitemaps_enabled', '__return_false' );
@mitchellkrogza
mitchellkrogza / disable-wp-lazy-load
Created June 6, 2021 14:05
Disable Wordpress Lazy Load
add_filter( 'wp_lazy_loading_enabled', '__return_false' );
@mitchellkrogza
mitchellkrogza / disable-wp-image-scaling
Created June 6, 2021 14:06
Disable Wordpress Image Scaling
add_filter( 'big_image_size_threshold', '__return_false' );
@mitchellkrogza
mitchellkrogza / woo-notify-cancellation
Created June 6, 2021 14:07
WooCommerce - Notify Customer of Order Cancellation
function wc_cancelled_order_add_customer_email( $recipient, $order ){
return $recipient . ',' . $order->billing_email;
}
add_filter( 'woocommerce_email_recipient_cancelled_order', 'wc_cancelled_order_add_customer_email', 10, 2 );
@mitchellkrogza
mitchellkrogza / woo-increase-variations
Last active June 22, 2021 12:44
Woocommerce Increase Variations per Page (Admin)
// NOTE: Setting this too high (even 50) can cause freezing when saving variations
// A 400 Bad Request can be registered on wpadmin-ajax.php when too high
add_filter( 'woocommerce_admin_meta_boxes_variations_per_page', 'woo_increase_variations_per_page' );
function woo_increase_variations_per_page() {
return 50;
}
@mitchellkrogza
mitchellkrogza / woo-change-add-to-cart-button-text
Created June 6, 2021 14:09
Woocommerce Change Add to Cart Button Text
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' );
function woocommerce_custom_single_add_to_cart_text() {
return __( 'Buy Now', 'woocommerce' );
}
@mitchellkrogza
mitchellkrogza / woocommerce-ninja-product-enquiry-form
Created June 7, 2021 10:54
Replace Woocommerce Product Enquiry Form with Ninja Form
// Include a Ninja Forms form in a product page. Different forms for simple and variable products.
add_filter( 'the_content', 'ninja_product_enquiry_form' );
function ninja_product_enquiry_form( $content ) {
if ( class_exists( 'woocommerce' ) && is_product() && is_main_query() ) {
global $product;
if ( 'simple' == $product->get_type() ) {
ob_start();
Ninja_Forms()->display( 3 ); // Equivalent to shortcode: [ninja_form id=3]
return $content . ob_get_clean();
}