Banned - Репутация: 34
- Webmoney BL: ?
| Скажите пожалуйста, что в этом коде дописать, чтоб переводились тайтлы, а не только текст страницы. Сейчас оно работает так: переводится текст страницы, а заголовок остается на исходном языке. Помогите, буду очень признателен, если за деньги, то договоримся, очень нужно. <?php /* Plugin Name: fromKvantTranslater Plugin URI: http://localhost Description: Translate posts Version: 1.0.0 Author: Kvant Author URI: http://localhost */ /* Copyright 2012 December (email : kvaant {at} gmail.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ function kvant_add_admin_page() { add_options_page('ВыполнеРЅРёРµ перевода','ПерРводчик',8,translate_options,'k vant_options_page'); } function kvant_options_page() { add_option('kvant_client_id','РќРµ задано'); add_option('kvant_client_secret','РќРµ задано'); //echo '<h2>Задайте настройки</h2>'; //kvant_set_options(); echo '<h2>Выполнить перевод</h2>'; kvant_translate(); } /*function kvant_set_options() { }*/ function kvant_translate() { echo '<form name="translate_form" method="post" action="'.$_SERVER['PHP_SELF'].'?page=translate_options"> <input type="submit" name="translate_button" value="Перевести"></form>'; if(isset($_POST['translate_button'])) { global $wpdb; $sql = 'SELECT ID,post_content FROM wp_posts'; $result = $wpdb->get_results($sql, ARRAY_A); echo '<table cellpadding="0" cellspacing="0" style="text-align:center;margin-top:50px;width:98%;"> <tr style="background-color: #ffffd9;"> <th style="width:200px;padding:5px;">Отве С‚ яндекса</th> <th style="width:100px;padding:5px;">ID</th> <th style="width:200px;padding:5px;">Запи сано РІ базу</th> <th style="width:200px;padding:5px;">Част СЊ перевода (300 символов)</th> </tr>'; $wpdb->show_errors(); $colorTB = 'background-color:#f0f3f6'; foreach ($result as $cat) { $colorYA = 'color:#990000'; $colorSV = 'color:#990000'; $len = mb_strlen($cat['post_content'],'utf-8'); $num = ceil($len/1500); $text = ''; $ans = true; //Разбиваем РїРѕ кускам Рё переводим for($i=0;$i<$num;$i++) { //Переводим $get= json_decode(file_get_contents('http://translate.yandex.net/api/v1/tr.json/translate?lang=ru-uk&text='.urlencode(substr($cat['post_content'],$i*1500,1500)))); if($get->code == 200) { $text = $text.$get->text[0]; } else { break; $ans = false; } } if($ans) { //Записываем РІ базу $my_post = array(); $my_post['ID'] = $cat['ID']; $my_post['post_content'] = $text; // Обновляем данные РІ БД $up = wp_update_post($my_post); //Прверяем статус сохранения РІ базу if($up) { $up = 'Сохранено'; $colorSV ='color:#009900'; } else $up = 'РќРµ сохранено'; $colorYA ='color:#009900'; } else { //Если сервер РЅРµ ответил то РЅРµ сохраняем РІ базу $up = 'РќРµ сохранено'; } echo ' <tr style="'.$colorTB.'"> <td style="padding:5px;'.$colorYA.'">'.$get->code.'</td> <td style="padding:5px;color:#0000ff;">'.$cat['ID'].'</td> <td style="padding:5px;'.$colorSV.'">'.$up.'</td> <td style="padding:5px;text-align:left;"><xmp style="margin:0;">'.substr($text,0,100).'</xmp><xmp style="margin:0;">'.substr($text,100,100).'</xmp><xmp style="margin:0;">'.substr($text,200,100).'</xmp></td> </tr>'; if($colorTB == 'background-color:#f0f3f6') $colorTB = 'background-color:#f6f9fa'; else $colorTB = 'background-color:#f0f3f6'; } echo '</table>'; } } add_action('admin_menu','kvant_add_admin_page') ?> |