WordPress disable theme update

If you have made custom changes to a WordPress theme and don’t want to upgrade to a new version, that is offered to you, open style.css in theme’s directory.
At the top you will find a big comment with theme’s version, name, author information etc.
Change the version in this comment to a big number, e.g. 9.9

Before:

Version: 1.7

After:

Version: 9.9

Go to WordPress update screen and update for this theme will disappear.

Speed up Woocommerce WordPress

Add following few lines into functions.php ( in your theme directory ), at the very bottom.


add_action( 'wp_enqueue_scripts', 'remove_woocommerce_when_not_needed', 99 );

function remove_woocommerce_when_not_needed() {
	remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );

	if ( function_exists( 'is_woocommerce' ) ) {

		if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
			// dequeue styles
			wp_dequeue_style( 'woocommerce_frontend_styles' );
			wp_dequeue_style( 'woocommerce_fancybox_styles' );
			wp_dequeue_style( 'woocommerce_chosen_styles' );
			wp_dequeue_style( 'woocommerce-general' );
			wp_dequeue_style( 'woocommerce-layout' );
			wp_dequeue_style( 'woocommerce-smallscreen' );
			wp_dequeue_style( 'sv-wc-payment-gateway-payment-form' );

			// dequeue scripts
			wp_dequeue_script( 'wc_price_slider' );
			wp_dequeue_script( 'wc-single-product' );
			wp_dequeue_script( 'wc-add-to-cart' );
			wp_dequeue_script( 'wc-cart-fragments' );
			wp_dequeue_script( 'wc-checkout' );
			wp_dequeue_script( 'wc-add-to-cart-variation' );
			wp_dequeue_script( 'wc-single-product' );
			wp_dequeue_script( 'wc-cart' );
			wp_dequeue_script( 'wc-chosen' );
			wp_dequeue_script( 'woocommerce' );
			wp_dequeue_script( 'jquery-blockui' );
			wp_dequeue_script( 'jquery-placeholder' );
			wp_dequeue_script( 'fancybox' );
			wp_dequeue_script( 'jqueryui' );
			wp_dequeue_script( 'braintree-data' );
			wp_dequeue_script( 'braintree-js' );
			wp_dequeue_script( 'sv-wc-payment-gateway-payment-form');
		}
	}
}

Scripts checks if the page you are on actually needs woocommerce component ( e.g. product page, checkout page .. ) – if not, it will remove all scripts and styles related to Woocommerce and Braintree.

It’s also possible to disable woocommerce entirely on these pages through dedicated plugin – https://wordpress.org/plugins/plugin-organizer/

Also make sure you update maximum memory limit https://phpsolved.com/wordpress-adjust-maximum-memory-limit/

Braintree Paypal – Please try a different payment method

If you got any of these errors
Oops, something went wrong. Please try a different payment method.
Error: This PayPal integration does not support this currency
Hups, něco se pokazilo. Zkuste prosím jiný způsob platby.

or any other localized version of this message, the issue is not with b>Merchand ID, as official documentation might hint.
It’s the issue with plugin itself.

Open this file wp-content/plugins/woocommerce-gateway-paypal-powered-by-braintree/includes/class-wc-gateway-braintree.php
On line 108, you need to comment out the wp_enqueue_script() and replace it with a different ( up-to-date url )

public function enqueue_gateway_assets() {

	if ( $this->is_available() ) {

		// braintree.js library
		wp_enqueue_script( 'braintree-js', 'https://js.braintreegateway.com/v2/braintree.js', array(), WC_Braintree::VERSION, true );

		parent::enqueue_gateway_assets();
	}
}

becomes

public function enqueue_gateway_assets() {

	if ( $this->is_available() ) {

		// braintree.js library
		// wp_enqueue_script( 'braintree-js', 'https://js.braintreegateway.com/v2/braintree.js', array(), WC_Braintree::VERSION, true );
		wp_enqueue_script( 'braintree-js', 'https://js.braintreegateway.com/js/braintree-2.32.1.min.js', array(), WC_Braintree::VERSION, true );
		parent::enqueue_gateway_assets();
	}
}

That’s it, works without adding additional Merchant ID. Simply but, the JS used in official plugin is outdated.