PHP code example of inpsyde / translation-cache

1. Go to this page and download the library: Download inpsyde/translation-cache library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

inpsyde / translation-cache example snippets


 load_plugin_textdomain( 'some-plugin-txt-domain', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 

function invalidate_some_plugin_translation_cache() {
	if ( class_exists( 'Inpsyde\TranslationCache\MoCache' ) ) {
		Inpsyde\TranslationCache\MoCache::flush_cache( 'some-plugin-txt-domain' );
    }
}
 
register_activation_hook(
    WP_PLUGIN_DIR . '/some-plugin-dir/some-plugin-filename.php',
    'invalidate_some_plugin_translation_cache'
);

register_deactivation_hook(
    WP_PLUGIN_DIR . '/some-plugin-dir/some-plugin-filename.php',
    'invalidate_some_plugin_translation_cache'
);

add_filter( 'mocache_cache_version', function( $version, $domain ) {
    $plugin_path = WP_PLUGIN_DIR . '/some-plugin-dir/some-plugin-filename.php';
    $headers     = get_plugin_data( $plugin_file_path, FALSE, FALSE );
    
    return $headers['Version'];
}, 10, 2 );