Last active
December 17, 2015 15:29
-
-
Save brasofilo/5631817 to your computer and use it in GitHub Desktop.
GlotPress plugin to hide Google Translate, which doesn't work anymore with GP.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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