• Resolved generosus

    (@generosus)


    How can we disable WordPress’ “Translations” update function? Can this be done via code snippet?

    We’ve tried what’s listed below, but are still getting translation updates from plugins such as MailPoet.

    Thank you.

    ———————-

    What We Tried (Not Working):

    • Adding to our wp-config.php file:
    define( 'WP_AUTO_UPDATE_TRANSLATION', false );
    • Using these code snippets:
    function ray_disable_bp_auto_translation( $retval, $item ) { // disable automatic translations for BuddyPress if ( 'plugin' === $item->type && 'mailpoet' === $item->slug ) { return false; } return $retval;}add_filter( 'auto_update_translation', 'ray_disable_bp_auto_translation', 10, 2 );

    or

    add_filter( 'async_update_translation', '__return_false' );
    add_filter( 'auto_update_translation', '__return_false' );

    or

    if( function_exists('add_filter') ){add_filter( 'auto_update_translation', '__return_false' );}
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator threadi

    (@threadi)

    add_filter( 'async_update_translation', '__return_false' );
    add_filter( 'auto_update_translation', '__return_false' );

    should actually work. With all the code you mentioned, this is the only one supported by the WordPress core. See also:
    https://wordpress.stackexchange.com/questions/300764/disabling-translation-update

    If that didn’t work for you, the question is where did you put the code? Ideally, it should be inserted in the functions.php of your child theme or via the code snippet plugin.

    Thread Starter generosus

    (@generosus)

    Thanks, @threadi.

    As it turns out, the issue that triggered our inquiry was the plugin, MailPoet. For some reason, the filters do work with MailPoet. You can try it yourself to confirm.

    So, to take care of our issue, we decided to use the following code snippet:

    add_filter( 'pre_http_request', function ( $result, $args, $url ) {
    
    if ( wp_parse_url( $url, PHP_URL_HOST ) === 'translate.wordpress.com/api/translations-updates/mailpoet/' ) {
        return new WP_Error( 'http_request_not_executed', __( 'User has blocked requests through HTTP.' ) );
    }
    
    return $result;
    
    }, 10, 3 );
    
    add_filter( 'pre_http_request', function ( $bFalse, $args, $sUrl ) {
    
    if ( strpos( $sUrl, '//translate.wordpress.com/api/translations-updates/mailpoet/' ) ) {
        return new WP_Error( 'http_request_not_executed', __( 'User has blocked requests through HTTP.') ); 
    }
    
    return $bFalse;
    
    }, 10, 3 );

    The code snippet was added to our functions.php file via the plugin, Code Snippets.

    Worked like a charm.

    Again, thank you for your support.

    Salud!

    Thread Starter generosus

    (@generosus)

    Errata:

    As it turns out, the issue that triggered our inquiry was the plugin, MailPoet. For some reason, the filters DO NOT work with MailPoet. You can try it yourself to confirm.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to Disable Translation Updates Using Code Snippet’ is closed to new replies.