Displaying admin notice when update for specific plugin is available

I use the German Market plugin for generating invoices and use a custom font which is not integrated into the plugin by default, so I have to re-upload it after updating the plugin. So I do not forget this, I implemented an admin notice which is displayed if a German Market update is available. That is not very difficult, and this is the complete code:

 * Display admin notice so I remember uploading the Clavo font after updating German Market
function fbn_german_market_typography_notice() {
    $update_plugins_transient = get_site_transient( 'update_plugins' );
    if ( $update_plugins_transient->response['woocommerce-german-market/WooCommerce-German-Market.php'] ) {
        add_action( 'all_admin_notices', function () { ?>
            <div class="notice notice-warning">
                <p><strong>Nach dem »German Market«-Update den Clavo-Font für Rechnungen wieder hochladen!</strong></p>
        <?php } );

add_action( 'admin_init', 'fbn_german_market_typography_notice' );

I hook fbn_german_market_typography_notice() to admin_init. First, the function saves the value of the update_plugins transient, which stores information about available plugin updates. If $update_plugins_transient->response['woocommerce-german-market/WooCommerce-German-Market.php'] is not empty, an update is available.

In this case, the admin notice is displayed (I use all_admin_notices, so the notice is not only showed in the network admin), which hopefully will remind me to upload the font for the invoices … 🙂

Of course, the array key is different for every plugin. You can take a look at the value of the transient via var_dump( $update_plugins_transient ); to find the correct key.

PS: More on admin notices in the post »Admin Notices in Plugin UIs« by Caspar Hübinger.

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' );