If you need further custom work, you can deactivate all essential hooks using this code example. The code needs to be placed in a plugin, not in functions.php file from the theme because of hook precedence. The hook is executed very early, on plugins_loaded action.
<?php | |
add_action( 'trp_before_running_hooks', 'trpc_remove_hooks_to_disable_gettext_translation', 10, 1); | |
function trpc_remove_hooks_to_disable_gettext_translation( $trp_loader ){ | |
$trp_loader->remove_hook( 'init', 'create_gettext_translated_global' ); | |
$trp_loader->remove_hook( 'shutdown', 'machine_translate_gettext' ); | |
} |
If the project requires you to place the code in functions.php, you will have to use a different approach to removing hooks. Here’s an example on how to get the component object that you need:
/* This particular code example refers to removing the TranslatePress search capability in secondary languages. */ | |
// Use a different hook if 'init' is not executed early enough | |
add_action('init', 'trpc_remove_search_hook'); | |
function trpc_remove_search_hook(){ | |
$trp = TRP_Translate_Press::get_trp_instance(); | |
// fetch the component needed by replacing 'search' with the name of the component. Name of all components are found in class-translatepress.php | |
$trp_search = $trp->get_component('search'); | |
// Use default WordPress function remove_filter or remove_action. Make sure to specifiy priority too. | |
remove_filter('pre_get_posts', array($trp_search,'trp_search_filter'), 99999999 ); | |
} |