Version Description
Download this release
Release Info
Developer | oferwald |
Plugin | Transposh WordPress Translation |
Version | 0.3.6 |
Comparing to | |
See all releases |
Code changes from version 0.3.5 to 0.3.6
- core/constants.php +1 -1
- core/parser.php +61 -45
- core/shd/simple_html_dom.php +2 -1
- core/utils.php +39 -0
- readme.txt +6 -1
- transposh.php +86 -8
- transposh_admin.php +11 -1
- transposh_db.php +73 -33
- transposh_options.php +13 -1
- transposh_widget.php +1 -1
core/constants.php
CHANGED
@@ -91,7 +91,7 @@ $rtl_languages = array("ar", "he", "fa", "yi");
|
|
91 |
//Define the new capability that will be assigned to roles - translator
|
92 |
define("TRANSLATOR", 'translator');
|
93 |
|
94 |
-
define("TRANSPOSH_PLUGIN_VER",'0.3.
|
95 |
|
96 |
//Define segment id prefix, will be included in span tag. also used as class identifier
|
97 |
define("SPAN_PREFIX", "tr_");
|
91 |
//Define the new capability that will be assigned to roles - translator
|
92 |
define("TRANSLATOR", 'translator');
|
93 |
|
94 |
+
define("TRANSPOSH_PLUGIN_VER",'0.3.6');
|
95 |
|
96 |
//Define segment id prefix, will be included in span tag. also used as class identifier
|
97 |
define("SPAN_PREFIX", "tr_");
|
core/parser.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
* You should have received a copy of the GNU General Public License
|
15 |
* along with this program; if not, write to the Free Software
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 |
-
|
18 |
|
19 |
require_once("shd/simple_html_dom.php");
|
20 |
|
@@ -37,8 +37,8 @@ class parser {
|
|
37 |
public $is_edit_mode;
|
38 |
public $is_auto_translate;
|
39 |
public $feed_fix;
|
40 |
-
|
41 |
-
|
42 |
/**
|
43 |
* Determine if the current position in buffer is a white space.
|
44 |
* @param char $char
|
@@ -168,8 +168,8 @@ class parser {
|
|
168 |
return true;
|
169 |
}
|
170 |
$entities = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐ'.
|
171 |
-
|
172 |
-
|
173 |
return (stripos($entities, $entity) !== FALSE);
|
174 |
}
|
175 |
|
@@ -283,7 +283,7 @@ class parser {
|
|
283 |
}
|
284 |
if (trim($node->outertext)) {
|
285 |
$this->parsetext($node->outertext);
|
286 |
-
}
|
287 |
}
|
288 |
// for anchors we will rewrite urls if we can
|
289 |
elseif ($node->tag == 'a') {
|
@@ -304,6 +304,10 @@ class parser {
|
|
304 |
elseif ($node->tag == 'select') {
|
305 |
$this->inselect = $level;
|
306 |
}
|
|
|
|
|
|
|
|
|
307 |
|
308 |
// titles are also good places to translate, exist in a, img, abbr, acronym
|
309 |
if ($node->title) $this->parsetext($node->title);
|
@@ -370,6 +374,16 @@ class parser {
|
|
370 |
return $this->html;
|
371 |
}
|
372 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
373 |
// actually translate tags
|
374 |
// texts are first
|
375 |
foreach ($this->html->find('text') as $e) {
|
@@ -387,7 +401,8 @@ class parser {
|
|
387 |
}
|
388 |
else
|
389 |
if ($translated_text == null) $translated_text = $ep->phrase;
|
390 |
-
}
|
|
|
391 |
$span = '';
|
392 |
$spanend = '';
|
393 |
}
|
@@ -398,7 +413,7 @@ class parser {
|
|
398 |
}
|
399 |
}
|
400 |
if ($newtext) {
|
401 |
-
|
402 |
if (substr($newtext, 0, 4) == '<') {
|
403 |
$newtext = html_entity_decode($newtext);
|
404 |
}
|
@@ -414,50 +429,51 @@ class parser {
|
|
414 |
|
415 |
}
|
416 |
|
417 |
-
// now we handle the title attributes
|
418 |
-
|
419 |
-
|
420 |
-
$
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
|
|
428 |
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
|
|
440 |
}
|
441 |
}
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
}
|
448 |
}
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
}
|
454 |
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
|
|
459 |
}
|
460 |
-
|
461 |
}
|
462 |
|
463 |
// now we handle the meta content - which is simpler because they can't be edited or auto-translated
|
14 |
* You should have received a copy of the GNU General Public License
|
15 |
* along with this program; if not, write to the Free Software
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 |
+
*/
|
18 |
|
19 |
require_once("shd/simple_html_dom.php");
|
20 |
|
37 |
public $is_edit_mode;
|
38 |
public $is_auto_translate;
|
39 |
public $feed_fix;
|
40 |
+
//first three are html, later 4 come from feeds xml
|
41 |
+
protected $ignore_tags = array('script'=>1, 'style'=>1, 'code'=>1,'link'=>1,'wfw:commentrss'=>1,'comments'=>1,'guid'=>1);
|
42 |
/**
|
43 |
* Determine if the current position in buffer is a white space.
|
44 |
* @param char $char
|
168 |
return true;
|
169 |
}
|
170 |
$entities = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐ'.
|
171 |
+
'ÑÒÓÔÕÖØÙÚÛÜÝÞß'.
|
172 |
+
'øùÿ';
|
173 |
return (stripos($entities, $entity) !== FALSE);
|
174 |
}
|
175 |
|
283 |
}
|
284 |
if (trim($node->outertext)) {
|
285 |
$this->parsetext($node->outertext);
|
286 |
+
}
|
287 |
}
|
288 |
// for anchors we will rewrite urls if we can
|
289 |
elseif ($node->tag == 'a') {
|
304 |
elseif ($node->tag == 'select') {
|
305 |
$this->inselect = $level;
|
306 |
}
|
307 |
+
// in submit type inputs, we want to translate the value
|
308 |
+
elseif ($node->tag == 'input' && $node->type =='submit') {
|
309 |
+
$this->parsetext($node->value);
|
310 |
+
}
|
311 |
|
312 |
// titles are also good places to translate, exist in a, img, abbr, acronym
|
313 |
if ($node->title) $this->parsetext($node->title);
|
374 |
return $this->html;
|
375 |
}
|
376 |
|
377 |
+
// fix urls on feed
|
378 |
+
if ($this->feed_fix) {
|
379 |
+
|
380 |
+
foreach (array('link','wfw:commentrss','comments','guid') as $tag) {
|
381 |
+
foreach ($this->html->find($tag) as $e) {
|
382 |
+
$e->innertext = call_user_func_array($this->url_rewrite_func,array($e->innertext));
|
383 |
+
}
|
384 |
+
}
|
385 |
+
}
|
386 |
+
|
387 |
// actually translate tags
|
388 |
// texts are first
|
389 |
foreach ($this->html->find('text') as $e) {
|
401 |
}
|
402 |
else
|
403 |
if ($translated_text == null) $translated_text = $ep->phrase;
|
404 |
+
}
|
405 |
+
else {
|
406 |
$span = '';
|
407 |
$spanend = '';
|
408 |
}
|
413 |
}
|
414 |
}
|
415 |
if ($newtext) {
|
416 |
+
/* if ($this->feed_fix) {
|
417 |
if (substr($newtext, 0, 4) == '<') {
|
418 |
$newtext = html_entity_decode($newtext);
|
419 |
}
|
429 |
|
430 |
}
|
431 |
|
432 |
+
// now we handle the title attributes (and the value of submit buttons)
|
433 |
+
foreach (array('title','value') as $title) {
|
434 |
+
$hidden_phrases = array();
|
435 |
+
foreach ($this->html->find('['.$title.']') as $e) {
|
436 |
+
$span = '';
|
437 |
+
$spanend = '';
|
438 |
+
$right = '';
|
439 |
+
$newtext = '';
|
440 |
+
// when we already have a parent outertext we'll have to update it directly
|
441 |
+
if ($e->parent->_[HDOM_INFO_OUTER]) {
|
442 |
+
$saved_outertext = $e->outertext;
|
443 |
+
}
|
444 |
|
445 |
+
foreach ($e->nodes as $ep) {
|
446 |
+
if ($ep->tag == 'phrase') {
|
447 |
+
list ($translated_text, $source) = call_user_func_array($this->fetch_translate_func,array($ep->phrase, $this->lang));
|
448 |
+
if (($this->is_edit_mode || ($this->is_auto_translate && $translated_text == null)) && $ep->inbody) {
|
449 |
+
// prevent duplicate translation (title = text)
|
450 |
+
if (strpos($e->innertext,base64_url_encode($ep->phrase)) === false) {
|
451 |
+
//no need to translate span the same hidden phrase more than once
|
452 |
+
if (!in_array($ep->phrase, $hidden_phrases)) {
|
453 |
+
$span .= $this->create_edit_span($ep->phrase, $translated_text, $source, true)."</span>";
|
454 |
+
//
|
455 |
+
$hidden_phrases[] = $ep->phrase;
|
456 |
+
}
|
457 |
}
|
458 |
}
|
459 |
+
if ($translated_text) {
|
460 |
+
list ($left, $right) = explode($ep->phrase, $e->$title, 2);
|
461 |
+
$newtext .= $left.$translated_text;
|
462 |
+
$e->$title = $right;
|
463 |
+
}
|
464 |
}
|
465 |
}
|
466 |
+
if ($newtext) {
|
467 |
+
$e->$title = $newtext.$right;
|
468 |
+
|
469 |
+
}
|
|
|
470 |
|
471 |
+
$e->outertext .= $span;
|
472 |
+
// this is where we update in the outercase issue
|
473 |
+
if ($e->parent->_[HDOM_INFO_OUTER]) {
|
474 |
+
$e->parent->outertext = implode ($e->outertext,explode($saved_outertext,$e->parent->outertext,2));
|
475 |
+
}
|
476 |
}
|
|
|
477 |
}
|
478 |
|
479 |
// now we handle the meta content - which is simpler because they can't be edited or auto-translated
|
core/shd/simple_html_dom.php
CHANGED
@@ -497,7 +497,7 @@ class simple_html_dom {
|
|
497 |
protected $token_slash = " />\r\n\t";
|
498 |
protected $token_attr = ' >';
|
499 |
// use isset instead of in_array, performance boost about 30%...
|
500 |
-
protected $self_closing_tags = array('img'=>1, 'br'=>1, 'input'=>1, 'meta'=>1, '
|
501 |
protected $block_tags = array('root'=>1, 'body'=>1, 'form'=>1, 'div'=>1, 'span'=>1, 'table'=>1);
|
502 |
protected $optional_closing_tags = array(
|
503 |
'tr'=>array('tr'=>1, 'td'=>1, 'th'=>1),
|
@@ -509,6 +509,7 @@ class simple_html_dom {
|
|
509 |
'dl'=>array('dd'=>1, 'dt'=>1),
|
510 |
'p'=>array('p'=>1),
|
511 |
'nobr'=>array('nobr'=>1),
|
|
|
512 |
);
|
513 |
|
514 |
function __construct($str=null) {
|
497 |
protected $token_slash = " />\r\n\t";
|
498 |
protected $token_attr = ' >';
|
499 |
// use isset instead of in_array, performance boost about 30%...
|
500 |
+
protected $self_closing_tags = array('img'=>1, 'br'=>1, 'input'=>1, 'meta'=>1, 'hr'=>1, 'base'=>1, 'embed'=>1, 'spacer'=>1);
|
501 |
protected $block_tags = array('root'=>1, 'body'=>1, 'form'=>1, 'div'=>1, 'span'=>1, 'table'=>1);
|
502 |
protected $optional_closing_tags = array(
|
503 |
'tr'=>array('tr'=>1, 'td'=>1, 'th'=>1),
|
509 |
'dl'=>array('dd'=>1, 'dt'=>1),
|
510 |
'p'=>array('p'=>1),
|
511 |
'nobr'=>array('nobr'=>1),
|
512 |
+
'link'=>array('link'=>1),
|
513 |
);
|
514 |
|
515 |
function __construct($str=null) {
|
core/utils.php
CHANGED
@@ -159,6 +159,45 @@ function rewrite_url_lang_param($url,$home_url, $enable_permalinks_rewrite, $lan
|
|
159 |
return $url;
|
160 |
}
|
161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
/**
|
163 |
* glue a parse_url array back to a url
|
164 |
* @param array $parsed url_parse style array
|
159 |
return $url;
|
160 |
}
|
161 |
|
162 |
+
function get_language_from_url($url, $home_url) {
|
163 |
+
|
164 |
+
$parsedurl = @parse_url($url);
|
165 |
+
|
166 |
+
//option 1, lanaguage is in the query ?lang=xx
|
167 |
+
if (isset($parsedurl['query'])) {
|
168 |
+
$params = explode('&',$parsedurl['query']);
|
169 |
+
foreach ($params as $key => $param) {
|
170 |
+
if (stripos($param,LANG_PARAM) === 0) {
|
171 |
+
return ($params[$key]);
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
//option 2, language is in permalink
|
177 |
+
|
178 |
+
//cleanup lang identifier in permalinks
|
179 |
+
//remove the language from the url permalink (if in start of path, and is a defined language)
|
180 |
+
$home_path = rtrim(parse_url($home_url,PHP_URL_PATH),"/");
|
181 |
+
//
|
182 |
+
if ($home_path && strpos($parsedurl['path'], $home_path) === 0) {
|
183 |
+
//
|
184 |
+
$parsedurl['path'] = substr($parsedurl['path'],strlen($home_path));
|
185 |
+
// $gluebackhome = true;
|
186 |
+
}
|
187 |
+
|
188 |
+
if (strlen($parsedurl['path']) > 2) {
|
189 |
+
$secondslashpos = strpos($parsedurl['path'], "/",1);
|
190 |
+
if (!$secondslashpos) $secondslashpos = strlen($parsedurl['path']);
|
191 |
+
$prevlang = substr($parsedurl['path'],1,$secondslashpos-1);
|
192 |
+
if (isset ($GLOBALS['languages'][$prevlang])) {
|
193 |
+
//
|
194 |
+
//$parsedurl['path'] = substr($parsedurl['path'],$secondslashpos);
|
195 |
+
return $prevlang;
|
196 |
+
}
|
197 |
+
}
|
198 |
+
return false;
|
199 |
+
}
|
200 |
+
|
201 |
/**
|
202 |
* glue a parse_url array back to a url
|
203 |
* @param array $parsed url_parse style array
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://transposh.org/donate/
|
|
4 |
Tags: translation, widget, filter, bilingual, multilingual, transposh, language, crowdsourcing, context, wiki, RTL, Hebrew, Spanish, French, Russian, English, Arabic, Portuguese
|
5 |
Requires at least: 2.7
|
6 |
Tested up to: 2.8.6
|
7 |
-
Stable tag: 0.3.
|
8 |
|
9 |
Transposh filter allows in context quick translation of websites, it allows you to crowd-source the translation to your users
|
10 |
|
@@ -18,6 +18,7 @@ Transposh translation filter for WordPress offers a unique approach to blog tran
|
|
18 |
* Multiple selection for widget appearances
|
19 |
* Translation of external plugins with no changes
|
20 |
* Automatic translation mode for all content (including comments!)
|
|
|
21 |
* Fine grained control for advanced users
|
22 |
|
23 |
***We are focused on:***
|
@@ -119,6 +120,10 @@ change the .css from transparent background to your page background color. And l
|
|
119 |
5. Widget style selection
|
120 |
|
121 |
== Changelog ==
|
|
|
|
|
|
|
|
|
122 |
= 2009/11/26 - 0.3.5 =
|
123 |
* Enabled auto-translation to all editable languages on the admin side
|
124 |
* Alternate posting methods (thanks Andre)
|
4 |
Tags: translation, widget, filter, bilingual, multilingual, transposh, language, crowdsourcing, context, wiki, RTL, Hebrew, Spanish, French, Russian, English, Arabic, Portuguese
|
5 |
Requires at least: 2.7
|
6 |
Tested up to: 2.8.6
|
7 |
+
Stable tag: 0.3.6
|
8 |
|
9 |
Transposh filter allows in context quick translation of websites, it allows you to crowd-source the translation to your users
|
10 |
|
18 |
* Multiple selection for widget appearances
|
19 |
* Translation of external plugins with no changes
|
20 |
* Automatic translation mode for all content (including comments!)
|
21 |
+
* Translated languages are searchable
|
22 |
* Fine grained control for advanced users
|
23 |
|
24 |
***We are focused on:***
|
120 |
5. Widget style selection
|
121 |
|
122 |
== Changelog ==
|
123 |
+
= 2009/12/02 - 0.3.6 =
|
124 |
+
* Translated language posts are now searchable with the default wordpress search box
|
125 |
+
* Rewrite urls inside feeds so translated feeds become a much more valid option (thanks datapharmer)
|
126 |
+
* Fixed transposh_widget global bug
|
127 |
= 2009/11/26 - 0.3.5 =
|
128 |
* Enabled auto-translation to all editable languages on the admin side
|
129 |
* Alternate posting methods (thanks Andre)
|
transposh.php
CHANGED
@@ -4,10 +4,10 @@
|
|
4 |
Plugin URI: http://transposh.org/
|
5 |
Description: Translation filter for WordPress, After enabling please set languages at the <a href="options-general.php?page=transposh">the options page</a> Want to help? visit our development site at <a href="http://trac.transposh.org/">trac.transposh.org</a>.
|
6 |
Author: Team Transposh
|
7 |
-
Version: 0.3.
|
8 |
Author URI: http://transposh.org/
|
9 |
License: GPL (http://www.gnu.org/licenses/gpl.txt)
|
10 |
-
|
11 |
|
12 |
/* Copyright © 2009 Transposh Team (website : http://transposh.org)
|
13 |
*
|
@@ -24,7 +24,7 @@
|
|
24 |
* You should have received a copy of the GNU General Public License
|
25 |
* along with this program; if not, write to the Free Software
|
26 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
-
|
28 |
|
29 |
//avoid direct calls to this file where wp core files not present
|
30 |
if (!function_exists ('add_action')) {
|
@@ -71,6 +71,8 @@ class transposh_plugin {
|
|
71 |
public $edit_mode;
|
72 |
/** @var string Error message displayed for the admin in case of failure*/
|
73 |
private $admin_msg;
|
|
|
|
|
74 |
|
75 |
/**
|
76 |
* class constructor
|
@@ -110,6 +112,10 @@ class transposh_plugin {
|
|
110 |
add_action('shutdown', array(&$this,'on_shutdown'));
|
111 |
add_action('wp_print_styles', array(&$this,'add_transposh_css'));
|
112 |
add_action('wp_print_scripts', array(&$this,'add_transposh_js'));
|
|
|
|
|
|
|
|
|
113 |
register_activation_hook(__FILE__, array(&$this,'plugin_activate'));
|
114 |
register_deactivation_hook(__FILE__,array(&$this,'plugin_deactivate'));
|
115 |
}
|
@@ -125,8 +131,8 @@ class transposh_plugin {
|
|
125 |
|
126 |
// Refrain from touching the administrative interface and important pages
|
127 |
if(stripos($_SERVER['REQUEST_URI'],'/wp-login.php') !== FALSE ||
|
128 |
-
|
129 |
-
|
130 |
|
131 |
return $buffer;
|
132 |
}
|
@@ -279,6 +285,14 @@ class transposh_plugin {
|
|
279 |
function on_parse_request($wp) {
|
280 |
|
281 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
$this->target_language = $wp->query_vars[LANG_PARAM];
|
283 |
if (!$this->target_language)
|
284 |
$this->target_language = $this->options->get_default_language();
|
@@ -513,9 +527,9 @@ class transposh_plugin {
|
|
513 |
// don't fix links pointing to real files as it will cause that the
|
514 |
// web server will not be able to locate them
|
515 |
if(stripos($href, '/wp-admin') !== FALSE ||
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
return $href;
|
520 |
}
|
521 |
$use_params = !$this->enable_permalinks_rewrite;
|
@@ -535,6 +549,70 @@ class transposh_plugin {
|
|
535 |
return array_merge( array('<a href="' . admin_url('options-general.php?page='.TRANSPOSH_ADMIN_PAGE_NAME) . '">Settings</a>'), $links );
|
536 |
}
|
537 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
538 |
}
|
539 |
$my_transposh_plugin = new transposh_plugin();
|
540 |
|
4 |
Plugin URI: http://transposh.org/
|
5 |
Description: Translation filter for WordPress, After enabling please set languages at the <a href="options-general.php?page=transposh">the options page</a> Want to help? visit our development site at <a href="http://trac.transposh.org/">trac.transposh.org</a>.
|
6 |
Author: Team Transposh
|
7 |
+
Version: 0.3.6
|
8 |
Author URI: http://transposh.org/
|
9 |
License: GPL (http://www.gnu.org/licenses/gpl.txt)
|
10 |
+
*/
|
11 |
|
12 |
/* Copyright © 2009 Transposh Team (website : http://transposh.org)
|
13 |
*
|
24 |
* You should have received a copy of the GNU General Public License
|
25 |
* along with this program; if not, write to the Free Software
|
26 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
27 |
+
*/
|
28 |
|
29 |
//avoid direct calls to this file where wp core files not present
|
30 |
if (!function_exists ('add_action')) {
|
71 |
public $edit_mode;
|
72 |
/** @var string Error message displayed for the admin in case of failure*/
|
73 |
private $admin_msg;
|
74 |
+
/** @var string Saved search variables*/
|
75 |
+
private $search_s;
|
76 |
|
77 |
/**
|
78 |
* class constructor
|
112 |
add_action('shutdown', array(&$this,'on_shutdown'));
|
113 |
add_action('wp_print_styles', array(&$this,'add_transposh_css'));
|
114 |
add_action('wp_print_scripts', array(&$this,'add_transposh_js'));
|
115 |
+
if ($this->options->get_enable_search_translate()) {
|
116 |
+
add_action('pre_get_posts', array(&$this,'pre_post_search'));
|
117 |
+
add_action('posts_where_request', array(&$this,'posts_where_request'));
|
118 |
+
}
|
119 |
register_activation_hook(__FILE__, array(&$this,'plugin_activate'));
|
120 |
register_deactivation_hook(__FILE__,array(&$this,'plugin_deactivate'));
|
121 |
}
|
131 |
|
132 |
// Refrain from touching the administrative interface and important pages
|
133 |
if(stripos($_SERVER['REQUEST_URI'],'/wp-login.php') !== FALSE ||
|
134 |
+
stripos($_SERVER['REQUEST_URI'],'/wp-admin/') !== FALSE ||
|
135 |
+
stripos($_SERVER['REQUEST_URI'],'/xmlrpc.php') !== FALSE) {
|
136 |
|
137 |
return $buffer;
|
138 |
}
|
285 |
function on_parse_request($wp) {
|
286 |
|
287 |
|
288 |
+
// this method allows posts from the search box to maintain the language,
|
289 |
+
// TODO - it has a bug of returning to original language following search, which can be resolved by removing search from widget urls, but maybe later...
|
290 |
+
if (isset($wp->query_vars['s'])) {
|
291 |
+
if (get_language_from_url($_SERVER['HTTP_REFERER'], $this->home_url) && !get_language_from_url($_SERVER['REQUEST_URI'], $this->home_url)) {
|
292 |
+
wp_redirect(rewrite_url_lang_param($_SERVER["REQUEST_URI"], $this->home_url, $this->enable_permalinks_rewrite, get_language_from_url($_SERVER['HTTP_REFERER'], $this->home_url), false));//."&stop=y");
|
293 |
+
exit;
|
294 |
+
}
|
295 |
+
}
|
296 |
$this->target_language = $wp->query_vars[LANG_PARAM];
|
297 |
if (!$this->target_language)
|
298 |
$this->target_language = $this->options->get_default_language();
|
527 |
// don't fix links pointing to real files as it will cause that the
|
528 |
// web server will not be able to locate them
|
529 |
if(stripos($href, '/wp-admin') !== FALSE ||
|
530 |
+
stripos($href, WP_CONTENT_URL) !== FALSE ||
|
531 |
+
stripos($href, '/wp-login') !== FALSE ||
|
532 |
+
stripos($href, '/.php') !== FALSE) {
|
533 |
return $href;
|
534 |
}
|
535 |
$use_params = !$this->enable_permalinks_rewrite;
|
549 |
return array_merge( array('<a href="' . admin_url('options-general.php?page='.TRANSPOSH_ADMIN_PAGE_NAME) . '">Settings</a>'), $links );
|
550 |
}
|
551 |
|
552 |
+
/**
|
553 |
+
* We use this to "steal" the search variables
|
554 |
+
* @param WP_Query $query
|
555 |
+
*/
|
556 |
+
function pre_post_search ($query) {
|
557 |
+
|
558 |
+
|
559 |
+
// we hide the search query var from further proccesing, because we do this later
|
560 |
+
if ($query->query_vars['s']) {
|
561 |
+
$this->search_s = $query->query_vars['s'];
|
562 |
+
$query->query_vars['s'] = "";
|
563 |
+
}
|
564 |
+
}
|
565 |
+
|
566 |
+
/**
|
567 |
+
* This is where we change the logic to include originals for search translation
|
568 |
+
* @param string $where Original where clause for getting posts
|
569 |
+
* @return string Modified where
|
570 |
+
*/
|
571 |
+
function posts_where_request ($where) {
|
572 |
+
|
573 |
+
|
574 |
+
// from query.php line 1742 (v2.8.6)
|
575 |
+
// If a search pattern is specified, load the posts that match
|
576 |
+
$q = &$GLOBALS['wp_query']->query_vars;
|
577 |
+
// returning the saved query strings
|
578 |
+
$q['s'] = $this->search_s;
|
579 |
+
if ( !empty($q['s']) ) {
|
580 |
+
// added slashes screw with quote grouping when done early, so done later
|
581 |
+
$q['s'] = stripslashes($q['s']);
|
582 |
+
if ( !empty($q['sentence']) ) {
|
583 |
+
$q['search_terms'] = array($q['s']);
|
584 |
+
} else {
|
585 |
+
preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q['s'], $matches);
|
586 |
+
$q['search_terms'] = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]);
|
587 |
+
}
|
588 |
+
$n = !empty($q['exact']) ? '' : '%';
|
589 |
+
$searchand = '';
|
590 |
+
foreach( (array) $q['search_terms'] as $term) {
|
591 |
+
// now we'll get possible translations for this term
|
592 |
+
$possible_original_terms = $this->database->get_orignal_phrases_for_search_term($term, $this->target_language);
|
593 |
+
$term = addslashes_gpc($term);
|
594 |
+
$search .= "{$searchand}(({$GLOBALS['wpdb']->posts}.post_title LIKE '{$n}{$term}{$n}') OR ({$GLOBALS['wpdb']->posts}.post_content LIKE '{$n}{$term}{$n}')";
|
595 |
+
foreach( (array) $possible_original_terms as $term) {
|
596 |
+
$term = addslashes_gpc($term);
|
597 |
+
$search .= " OR ({$GLOBALS['wpdb']->posts}.post_title LIKE '{$n}{$term}{$n}') OR ({$GLOBALS['wpdb']->posts}.post_content LIKE '{$n}{$term}{$n}')";
|
598 |
+
}
|
599 |
+
// we moved this to here, so it really closes all of them
|
600 |
+
$search .= ")";
|
601 |
+
$searchand = ' AND ';
|
602 |
+
}
|
603 |
+
$term = $GLOBALS['wpdb']->escape($q['s']);
|
604 |
+
if (empty($q['sentence']) && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] )
|
605 |
+
$search .= " OR ({$GLOBALS['wpdb']->posts}.post_title LIKE '{$n}{$term}{$n}') OR ({$GLOBALS['wpdb']->posts}.post_content LIKE '{$n}{$term}{$n}')";
|
606 |
+
|
607 |
+
if ( !empty($search) ) {
|
608 |
+
$search = " AND ({$search}) ";
|
609 |
+
if ( !is_user_logged_in() )
|
610 |
+
$search .= " AND ({$GLOBALS['wpdb']->posts}.post_password = '') ";
|
611 |
+
}
|
612 |
+
}
|
613 |
+
|
614 |
+
return $search.$where;
|
615 |
+
}
|
616 |
}
|
617 |
$my_transposh_plugin = new transposh_plugin();
|
618 |
|
transposh_admin.php
CHANGED
@@ -100,7 +100,7 @@ class transposh_plugin_admin {
|
|
100 |
|
101 |
if($this->transposh->options->get_enable_permalinks() != $_POST[ENABLE_PERMALINKS]) {
|
102 |
$this->transposh->options->set_enable_permalinks($_POST[ENABLE_PERMALINKS]);
|
103 |
-
//rewrite rules - refresh
|
104 |
add_filter('rewrite_rules_array', 'update_rewrite_rules');
|
105 |
$GLOBALS['wp_rewrite']->flush_rules();
|
106 |
}
|
@@ -110,6 +110,7 @@ class transposh_plugin_admin {
|
|
110 |
$this->transposh->options->set_enable_auto_translate($_POST[ENABLE_AUTO_TRANSLATE]);
|
111 |
$this->transposh->options->set_enable_auto_post_translate($_POST[ENABLE_AUTO_POST_TRANSLATE]);
|
112 |
$this->transposh->options->set_enable_default_translate($_POST[ENABLE_DEFAULT_TRANSLATE]);
|
|
|
113 |
$this->transposh->options->set_enable_msn_translate($_POST[ENABLE_MSN_TRANSLATE]);
|
114 |
$this->transposh->options->set_msn_key($_POST[MSN_TRANSLATE_KEY]);
|
115 |
$this->transposh->options->update_options();
|
@@ -409,6 +410,15 @@ class transposh_plugin_admin {
|
|
409 |
echo '<input type="checkbox" value="1" name="'.ENABLE_DEFAULT_TRANSLATE.'" '.$this->checked ($this->transposh->options->get_enable_default_translate()).'/> '.
|
410 |
'Allow translation of default language - useful for sites with more than one major language';
|
411 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
}
|
413 |
|
414 |
function on_contentbox_generic_content($data) {
|
100 |
|
101 |
if($this->transposh->options->get_enable_permalinks() != $_POST[ENABLE_PERMALINKS]) {
|
102 |
$this->transposh->options->set_enable_permalinks($_POST[ENABLE_PERMALINKS]);
|
103 |
+
//rewrite rules - refresh. - because we want them set or unset upon this change
|
104 |
add_filter('rewrite_rules_array', 'update_rewrite_rules');
|
105 |
$GLOBALS['wp_rewrite']->flush_rules();
|
106 |
}
|
110 |
$this->transposh->options->set_enable_auto_translate($_POST[ENABLE_AUTO_TRANSLATE]);
|
111 |
$this->transposh->options->set_enable_auto_post_translate($_POST[ENABLE_AUTO_POST_TRANSLATE]);
|
112 |
$this->transposh->options->set_enable_default_translate($_POST[ENABLE_DEFAULT_TRANSLATE]);
|
113 |
+
$this->transposh->options->set_enable_search_translate($_POST[ENABLE_SEARCH_TRANSLATE]);
|
114 |
$this->transposh->options->set_enable_msn_translate($_POST[ENABLE_MSN_TRANSLATE]);
|
115 |
$this->transposh->options->set_msn_key($_POST[MSN_TRANSLATE_KEY]);
|
116 |
$this->transposh->options->update_options();
|
410 |
echo '<input type="checkbox" value="1" name="'.ENABLE_DEFAULT_TRANSLATE.'" '.$this->checked ($this->transposh->options->get_enable_default_translate()).'/> '.
|
411 |
'Allow translation of default language - useful for sites with more than one major language';
|
412 |
|
413 |
+
/**
|
414 |
+
* Insert the option to enable search in translated languages
|
415 |
+
* Enabled by default.
|
416 |
+
* @since 0.3.6
|
417 |
+
*/
|
418 |
+
echo '<h4>Enable search in translated languages</h4>';
|
419 |
+
echo '<input type="checkbox" value="1" name="'.ENABLE_SEARCH_TRANSLATE.'" '.$this->checked ($this->transposh->options->get_enable_search_translate()).'/> '.
|
420 |
+
'Allow search of translated languages, in those languages (and the original language)';
|
421 |
+
|
422 |
}
|
423 |
|
424 |
function on_contentbox_generic_content($data) {
|
transposh_db.php
CHANGED
@@ -14,7 +14,7 @@
|
|
14 |
* You should have received a copy of the GNU General Public License
|
15 |
* along with this program; if not, write to the Free Software
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 |
-
|
18 |
|
19 |
|
20 |
/**
|
@@ -100,10 +100,10 @@ class transposh_database {
|
|
100 |
return $translated;
|
101 |
}
|
102 |
|
103 |
-
/*
|
104 |
* A new translation has been posted, update the translation database.
|
105 |
* This has changed since we now accept multiple translations at once
|
106 |
-
|
107 |
function update_translation() {
|
108 |
|
109 |
$ref=getenv('HTTP_REFERER');
|
@@ -120,7 +120,7 @@ class transposh_database {
|
|
120 |
//Check permissions, first the lanugage must be on the edit list. Then either the user
|
121 |
//is a translator or automatic translation if it is enabled.
|
122 |
if(!($this->transposh->options->is_editable_language($lang) &&
|
123 |
-
|
124 |
|
125 |
header("HTTP/1.0 401 Unauthorized translation");
|
126 |
exit;
|
@@ -186,7 +186,7 @@ class transposh_database {
|
|
186 |
if($result !== FALSE) {
|
187 |
// update the transaction log too
|
188 |
$log = "INSERT INTO ".$GLOBALS['wpdb']->prefix.TRANSLATIONS_LOG." (original, translated, lang, translated_by, source) ".
|
189 |
-
|
190 |
$result = $GLOBALS['wpdb']->query($log);
|
191 |
|
192 |
|
@@ -233,7 +233,7 @@ class transposh_database {
|
|
233 |
}
|
234 |
|
235 |
if(!($all_editable &&
|
236 |
-
|
237 |
|
238 |
header("HTTP/1.0 401 Unauthorized translation");
|
239 |
exit;
|
@@ -311,7 +311,7 @@ class transposh_database {
|
|
311 |
if($result !== FALSE) {
|
312 |
// update the transaction log too
|
313 |
$log = "INSERT INTO ".$GLOBALS['wpdb']->prefix.TRANSLATIONS_LOG." (original, translated, lang, translated_by, source) ".
|
314 |
-
|
315 |
$result = $GLOBALS['wpdb']->query($log);
|
316 |
|
317 |
|
@@ -325,9 +325,9 @@ class transposh_database {
|
|
325 |
exit;
|
326 |
}
|
327 |
|
328 |
-
/*
|
329 |
* Get translation history for some translation.
|
330 |
-
|
331 |
function get_translation_history($token, $lang) {
|
332 |
|
333 |
$ref=getenv('HTTP_REFERER');
|
@@ -362,10 +362,10 @@ class transposh_database {
|
|
362 |
header("Transposh: v-".TRANSPOSH_PLUGIN_VER." db_version-". DB_VERSION);
|
363 |
|
364 |
$query = "SELECT translated, translated_by, timestamp, source, user_login ".
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
|
370 |
|
371 |
$rows = $GLOBALS['wpdb']->get_results($query);
|
@@ -373,12 +373,12 @@ class transposh_database {
|
|
373 |
|
374 |
if($rows !== FALSE) {
|
375 |
echo '<table>' .
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
foreach ($rows as $row) {
|
383 |
if (is_null($row->user_login)) $row->user_login = $row->translated_by;
|
384 |
echo "<tr><td>{$row->translated}</td><td source=\"{$row->source}\"/><td user_id=\"{$row->translated_by}\">{$row->user_login}</td><td>{$row->timestamp}</td></tr>";
|
@@ -389,9 +389,9 @@ class transposh_database {
|
|
389 |
exit;
|
390 |
}
|
391 |
|
392 |
-
/*
|
393 |
* Setup the translation database.
|
394 |
-
|
395 |
function setup_db() {
|
396 |
|
397 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
@@ -403,10 +403,10 @@ class transposh_database {
|
|
403 |
|
404 |
|
405 |
$sql = "CREATE TABLE $table_name (original VARCHAR(255) NOT NULL,".
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
|
411 |
dbDelta($sql);
|
412 |
|
@@ -414,12 +414,12 @@ class transposh_database {
|
|
414 |
|
415 |
|
416 |
$sql = "CREATE TABLE $table_name (original VARCHAR(255) NOT NULL,".
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
|
424 |
dbDelta($sql);
|
425 |
update_option(TRANSPOSH_DB_VERSION, DB_VERSION);
|
@@ -453,9 +453,49 @@ class transposh_database {
|
|
453 |
$td = mysql2date(get_option('date_format').' '.get_option('time_format'), $row->timestamp);
|
454 |
//the_date();
|
455 |
echo "<p>On <strong>{$td}</strong><br/>user <strong>{$row->translated_by}</strong> translated<br/>".
|
456 |
-
|
457 |
-
|
458 |
}
|
459 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
460 |
}
|
461 |
?>
|
14 |
* You should have received a copy of the GNU General Public License
|
15 |
* along with this program; if not, write to the Free Software
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
17 |
+
*/
|
18 |
|
19 |
|
20 |
/**
|
100 |
return $translated;
|
101 |
}
|
102 |
|
103 |
+
/*
|
104 |
* A new translation has been posted, update the translation database.
|
105 |
* This has changed since we now accept multiple translations at once
|
106 |
+
*/
|
107 |
function update_translation() {
|
108 |
|
109 |
$ref=getenv('HTTP_REFERER');
|
120 |
//Check permissions, first the lanugage must be on the edit list. Then either the user
|
121 |
//is a translator or automatic translation if it is enabled.
|
122 |
if(!($this->transposh->options->is_editable_language($lang) &&
|
123 |
+
($this->transposh->is_translator() || ($source == 1 && $this->transposh->options->get_enable_auto_translate())))) {
|
124 |
|
125 |
header("HTTP/1.0 401 Unauthorized translation");
|
126 |
exit;
|
186 |
if($result !== FALSE) {
|
187 |
// update the transaction log too
|
188 |
$log = "INSERT INTO ".$GLOBALS['wpdb']->prefix.TRANSLATIONS_LOG." (original, translated, lang, translated_by, source) ".
|
189 |
+
"VALUES $logvalues";
|
190 |
$result = $GLOBALS['wpdb']->query($log);
|
191 |
|
192 |
|
233 |
}
|
234 |
|
235 |
if(!($all_editable &&
|
236 |
+
($this->transposh->is_translator() || ($source == 1 && $this->transposh->options->get_enable_auto_translate())))) {
|
237 |
|
238 |
header("HTTP/1.0 401 Unauthorized translation");
|
239 |
exit;
|
311 |
if($result !== FALSE) {
|
312 |
// update the transaction log too
|
313 |
$log = "INSERT INTO ".$GLOBALS['wpdb']->prefix.TRANSLATIONS_LOG." (original, translated, lang, translated_by, source) ".
|
314 |
+
"VALUES $logvalues";
|
315 |
$result = $GLOBALS['wpdb']->query($log);
|
316 |
|
317 |
|
325 |
exit;
|
326 |
}
|
327 |
|
328 |
+
/*
|
329 |
* Get translation history for some translation.
|
330 |
+
*/
|
331 |
function get_translation_history($token, $lang) {
|
332 |
|
333 |
$ref=getenv('HTTP_REFERER');
|
362 |
header("Transposh: v-".TRANSPOSH_PLUGIN_VER." db_version-". DB_VERSION);
|
363 |
|
364 |
$query = "SELECT translated, translated_by, timestamp, source, user_login ".
|
365 |
+
"FROM $table_name ".
|
366 |
+
"LEFT JOIN {$GLOBALS['wpdb']->prefix}users ON translated_by = {$GLOBALS['wpdb']->prefix}users.id ".
|
367 |
+
"WHERE original='$original' AND lang='$lang' ".
|
368 |
+
"ORDER BY timestamp DESC";
|
369 |
|
370 |
|
371 |
$rows = $GLOBALS['wpdb']->get_results($query);
|
373 |
|
374 |
if($rows !== FALSE) {
|
375 |
echo '<table>' .
|
376 |
+
'<thead>'.
|
377 |
+
'<tr>'.
|
378 |
+
'<th>Translated</th><th/><th>By</th><th>At</th>'.
|
379 |
+
'</tr>'.
|
380 |
+
'</thead>'.
|
381 |
+
'<tbody>';
|
382 |
foreach ($rows as $row) {
|
383 |
if (is_null($row->user_login)) $row->user_login = $row->translated_by;
|
384 |
echo "<tr><td>{$row->translated}</td><td source=\"{$row->source}\"/><td user_id=\"{$row->translated_by}\">{$row->user_login}</td><td>{$row->timestamp}</td></tr>";
|
389 |
exit;
|
390 |
}
|
391 |
|
392 |
+
/*
|
393 |
* Setup the translation database.
|
394 |
+
*/
|
395 |
function setup_db() {
|
396 |
|
397 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
|
403 |
|
404 |
|
405 |
$sql = "CREATE TABLE $table_name (original VARCHAR(255) NOT NULL,".
|
406 |
+
"lang CHAR(5) NOT NULL,".
|
407 |
+
"translated VARCHAR(255),".
|
408 |
+
"source TINYINT NOT NULL,".
|
409 |
+
"PRIMARY KEY (original, lang)) DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci";
|
410 |
|
411 |
dbDelta($sql);
|
412 |
|
414 |
|
415 |
|
416 |
$sql = "CREATE TABLE $table_name (original VARCHAR(255) NOT NULL,".
|
417 |
+
"lang CHAR(5) NOT NULL,".
|
418 |
+
"translated VARCHAR(255),".
|
419 |
+
"translated_by VARCHAR(15),".
|
420 |
+
"source TINYINT NOT NULL,".
|
421 |
+
"timestamp TIMESTAMP,".
|
422 |
+
"PRIMARY KEY (original, lang, timestamp)) DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci";
|
423 |
|
424 |
dbDelta($sql);
|
425 |
update_option(TRANSPOSH_DB_VERSION, DB_VERSION);
|
453 |
$td = mysql2date(get_option('date_format').' '.get_option('time_format'), $row->timestamp);
|
454 |
//the_date();
|
455 |
echo "<p>On <strong>{$td}</strong><br/>user <strong>{$row->translated_by}</strong> translated<br/>".
|
456 |
+
"\"<strong>{$row->original}</strong>\"<br/>to ".
|
457 |
+
"<strong style=\"color:red\">{$row->lang}</strong><br/>\"<strong>{$row->translated}</strong>\"</p>";
|
458 |
}
|
459 |
}
|
460 |
+
|
461 |
+
/**
|
462 |
+
* This function returns a list of candidate phrases which might contain a requested translated string
|
463 |
+
* @param string $term The search term
|
464 |
+
* @param string $language The language being searched
|
465 |
+
* @return array Original phrases in which $term appears
|
466 |
+
*/
|
467 |
+
function get_orignal_phrases_for_search_term($term, $language) {
|
468 |
+
$table_name = $GLOBALS['wpdb']->prefix . TRANSLATIONS_TABLE;
|
469 |
+
$n = '%';
|
470 |
+
$term = addslashes_gpc($term);
|
471 |
+
$query = "SELECT original
|
472 |
+
FROM `$table_name`
|
473 |
+
WHERE `lang` LIKE '$language'
|
474 |
+
AND `translated` LIKE '{$n}{$term}{$n}'";
|
475 |
+
//TODO wait for feedbacks to see if we should put a limit here.
|
476 |
+
|
477 |
+
|
478 |
+
$result = array();
|
479 |
+
$rows = $GLOBALS['wpdb']->get_results($query);
|
480 |
+
|
481 |
+
foreach ($rows as $row) {
|
482 |
+
$addme = true;
|
483 |
+
// now lets use the a-priori for reduction
|
484 |
+
// two possibilities for reduction, new is included in old, or some old includes this new
|
485 |
+
foreach ($result as $k => $r) {
|
486 |
+
// if our original is included in a string in the result, that is no longer needed...
|
487 |
+
if (stripos($r, $row->original) !== false) {
|
488 |
+
unset($result[$k]);
|
489 |
+
}
|
490 |
+
// if the other way around is true, we won't have to add it
|
491 |
+
if (stripos($row->original,$r) !== false) {
|
492 |
+
$addme = false;
|
493 |
+
}
|
494 |
+
}
|
495 |
+
if ($addme) $result[] = $row->original;
|
496 |
+
}
|
497 |
+
|
498 |
+
return $result;
|
499 |
+
}
|
500 |
}
|
501 |
?>
|
transposh_options.php
CHANGED
@@ -58,6 +58,8 @@ define("ENABLE_MSN_TRANSLATE", "enable_msntranslate");
|
|
58 |
define("MSN_TRANSLATE_KEY", "msn_key");
|
59 |
//Option to enable/disable default language translation
|
60 |
define("ENABLE_DEFAULT_TRANSLATE", "enable_default_translate");
|
|
|
|
|
61 |
//Option to enable/disable rewrite of permalinks
|
62 |
define("ENABLE_PERMALINKS", "enable_permalinks");
|
63 |
//Option to enable/disable footer scripts (2.8 and up)
|
@@ -174,6 +176,11 @@ class transposh_plugin_options {
|
|
174 |
return $this->options[ENABLE_DEFAULT_TRANSLATE];
|
175 |
}
|
176 |
|
|
|
|
|
|
|
|
|
|
|
177 |
function get_enable_auto_translate() {
|
178 |
if (!isset($this->options[ENABLE_AUTO_TRANSLATE])) return 1; // default is true
|
179 |
return $this->options[ENABLE_AUTO_TRANSLATE];
|
@@ -206,7 +213,7 @@ class transposh_plugin_options {
|
|
206 |
* @param pointer $option Points to the option in the options array
|
207 |
*/
|
208 |
private function set_value($val, &$option) {
|
209 |
-
if ($val
|
210 |
$option = $val;
|
211 |
$this->changed = true;
|
212 |
}
|
@@ -263,6 +270,11 @@ class transposh_plugin_options {
|
|
263 |
$this->set_value($val, $this->options[ENABLE_DEFAULT_TRANSLATE]);
|
264 |
}
|
265 |
|
|
|
|
|
|
|
|
|
|
|
266 |
function set_enable_auto_translate($val) {
|
267 |
$val = ($val) ? 1 : 0;
|
268 |
$this->set_value($val, $this->options[ENABLE_AUTO_TRANSLATE]);
|
58 |
define("MSN_TRANSLATE_KEY", "msn_key");
|
59 |
//Option to enable/disable default language translation
|
60 |
define("ENABLE_DEFAULT_TRANSLATE", "enable_default_translate");
|
61 |
+
//Option to enable/disable default language translation @since 0.3.6
|
62 |
+
define("ENABLE_SEARCH_TRANSLATE", "enable_search_translate");
|
63 |
//Option to enable/disable rewrite of permalinks
|
64 |
define("ENABLE_PERMALINKS", "enable_permalinks");
|
65 |
//Option to enable/disable footer scripts (2.8 and up)
|
176 |
return $this->options[ENABLE_DEFAULT_TRANSLATE];
|
177 |
}
|
178 |
|
179 |
+
function get_enable_search_translate() {
|
180 |
+
if (!isset($this->options[ENABLE_SEARCH_TRANSLATE])) return 1; // default is true
|
181 |
+
return $this->options[ENABLE_SEARCH_TRANSLATE];
|
182 |
+
}
|
183 |
+
|
184 |
function get_enable_auto_translate() {
|
185 |
if (!isset($this->options[ENABLE_AUTO_TRANSLATE])) return 1; // default is true
|
186 |
return $this->options[ENABLE_AUTO_TRANSLATE];
|
213 |
* @param pointer $option Points to the option in the options array
|
214 |
*/
|
215 |
private function set_value($val, &$option) {
|
216 |
+
if ($val !== $option) {
|
217 |
$option = $val;
|
218 |
$this->changed = true;
|
219 |
}
|
270 |
$this->set_value($val, $this->options[ENABLE_DEFAULT_TRANSLATE]);
|
271 |
}
|
272 |
|
273 |
+
function set_enable_search_translate($val) {
|
274 |
+
$val = ($val) ? 1 : 0;
|
275 |
+
$this->set_value($val, $this->options[ENABLE_SEARCH_TRANSLATE]);
|
276 |
+
}
|
277 |
+
|
278 |
function set_enable_auto_translate($val) {
|
279 |
$val = ($val) ? 1 : 0;
|
280 |
$this->set_value($val, $this->options[ENABLE_AUTO_TRANSLATE]);
|
transposh_widget.php
CHANGED
@@ -255,6 +255,6 @@ class transposh_plugin_widget {
|
|
255 |
* @param array $args Not needed
|
256 |
*/
|
257 |
function transposh_widget($args = array()) {
|
258 |
-
$my_transposh_plugin->widget->transposh_widget($args);
|
259 |
}
|
260 |
?>
|
255 |
* @param array $args Not needed
|
256 |
*/
|
257 |
function transposh_widget($args = array()) {
|
258 |
+
$GLOBALS['my_transposh_plugin']->widget->transposh_widget($args);
|
259 |
}
|
260 |
?>
|