Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
GlotPress plugin to hide Google Translate, which doesn't work anymore with GP.
<?php
/**
* Hide Google Translate elements from GlotPress interface
* Put this file in the folder: /glotpress/plugins/
*/
class Glot_No_Google extends GP_Plugin
{
private $pagenow = false;
function __construct()
{
parent::__construct();
$this->add_action( 'pre_tmpl_load', array( 'args' => 2 ) );
$this->add_action( 'gp_head' );
$this->add_action( 'gp_footer' );
}
function pre_tmpl_load( $template, $args )
{
if( 'translations' == $template )
$this->pagenow = true;
return $template;
}
function gp_head()
{
if( !$this->pagenow )
return;
echo '<style type="text/css">.gtranslate { display: none; }</style>';
}
function gp_footer()
{
if( !$this->pagenow )
return;
echo <<<HTML
<script type='text/javascript'>
jQuery(document).ready(function($) {
$('#bulk-actions-toolbar select option[value="gtranslate"]').remove();
});
</script>
HTML;
}
}
GP::$plugins->glot_no_google = new Glot_No_Google;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment