Modifying an existing customizer control

This post shows you how to modify an existing customizer control — helpful for the solution was a Gist by Marcio Duarte.

In my case, I wanted to add an active_callback to the header image control to only show it if the user is on a static front page. To get this done, we only need one line of code:

/** * Set active callback for the header image control. */ $wp_customize->get_control( 'header_image' )->active_callback = 'slug_is_static_front_page';
Code language: PHP (php)

You can modify the other control properties accordingly — a few examples can be found in the above-linked Gist. For the sake of completeness here is the callback function:

/** * Check if we are on a static front page. * * @param WP_Customize_Control $control Control object. * * @return bool */ function slug_is_static_front_page( $control ) { /** * Return true if is static front page. */ if ( is_front_page() && is_page() ) { return true; } else { return false; } }
Code language: PHP (php)

WordPress multisite with a mix of subdomains and subdirectories

While setting up multisite, you decide to use either subdomains or subdirectories — mixing both in one multisite is not possible without modifications. This post shows you how to run a multisite with subdomains and subdirectory sites. Continue reading "WordPress multisite with a mix of subdomains and subdirectories"

Modifying robots.txt for individual sites of a multisite install

WordPress creates a robots.txt dynamically. To overwrite it in a normal non-multisite installation, you can just upload a static robots.txt to the server. On a multisite install, this would overwrite the robots.txt for all sites, which is not always the wanted behavior. This post explains how you can modify robots.txt for individual sites of a multisite.

Continue reading "Modifying robots.txt for individual sites of a multisite install"

WooCommerce: same price regardless of taxes

In my online shop, customers from the EU have to pay their country’s VAT rate. Customers from the USA, for example, do not have to pay any VAT. If I set the price to 15 Euros in WooCommerce and specify that the prices include taxes, the default behavior is the following:

Customers from a country for which a tax rate is specified pay 15 Euros including their country’s tax rate. Customers from countries without a specified tax rate pay less than 15 Euros. I am not sure, but I think in this case the price is reduced by the tax rate from the shop’s base location. The desired effect is that these customers pay 15 Euros too, but without any included taxes.

The WooCommerce wiki on GitHub has the solution for that. You only have to insert the following line of code into your theme or into a plugin:

add_filter( 'woocommerce_adjust_non_base_location_prices', '__return_false' );
Code language: JavaScript (javascript)