Version Description
- WP 3.2+ ()
- WP 4.8 ()
- ()
- ()
- ()
()
support WP 3.2+ (support)
tested with WP 4.8 (support)
MultiSite support (core)
optimized plugin (core)
added settings link in plugins control panel (GUI)
added notices about new functions and its allocation to the plugin page (GUI)
Download this release
Release Info
Developer | YurchenkoEV |
Plugin | WP Translitera |
Version | 170212 |
Comparing to | |
See all releases |
Code changes from version 170114 to 170212
- languages/wp_translitera-ru_RU.mo +0 -0
- languages/wp_translitera-ru_RU.po +28 -12
- readme.txt +26 -5
- unistall.php +27 -0
- wp-translitera.php +127 -56
languages/wp_translitera-ru_RU.mo
CHANGED
Binary file
|
languages/wp_translitera-ru_RU.po
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: wp_translitera\n"
|
4 |
-
"POT-Creation-Date:
|
5 |
-
"PO-Revision-Date:
|
6 |
"Last-Translator: Evgenij Yurchenko <evgen@yur4enko.com>\n"
|
7 |
"Language-Team: \n"
|
8 |
"Language: ru_RU\n"
|
@@ -17,39 +17,47 @@ msgstr ""
|
|
17 |
"X-Poedit-KeywordsList: __\n"
|
18 |
"X-Poedit-SearchPath-0: wp-translitera.php\n"
|
19 |
|
20 |
-
#: wp-translitera.php:
|
21 |
msgid "Convert existing"
|
22 |
msgstr "Преобразовать существующие"
|
23 |
|
24 |
-
#: wp-translitera.php:
|
25 |
msgid "Pages and posts"
|
26 |
msgstr "Страницы и посты"
|
27 |
|
28 |
-
#: wp-translitera.php:
|
29 |
msgid "Headings, tags etc..."
|
30 |
msgstr "Рубрики, теги и тд"
|
31 |
|
32 |
-
#: wp-translitera.php:
|
33 |
msgid "Transliterate"
|
34 |
msgstr "Транслитерировать"
|
35 |
|
36 |
-
#: wp-translitera.php:
|
37 |
msgid "Settings"
|
38 |
msgstr "Настройки"
|
39 |
|
40 |
-
#: wp-translitera.php:
|
41 |
msgid "Use forces transliteration for title"
|
42 |
msgstr "Форсированный режим транслитерации"
|
43 |
|
44 |
-
#: wp-translitera.php:
|
45 |
msgid "Transliterate names of uploads files"
|
46 |
msgstr "Транслитерировать имена загружаемых файлов"
|
47 |
|
48 |
-
#: wp-translitera.php:
|
49 |
msgid "Transliterate 404 url"
|
50 |
msgstr "Транслитерация 404 ссылок"
|
51 |
|
52 |
-
#: wp-translitera.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
msgid ""
|
54 |
"File extensions, separated by commas , titles that do not need to "
|
55 |
"transliterate"
|
@@ -57,6 +65,14 @@ msgstr ""
|
|
57 |
"Расширения файлов, разделенные запятой, заголвки которых не нужно "
|
58 |
"транслитерировать"
|
59 |
|
60 |
-
#: wp-translitera.php:
|
61 |
msgid "Apply"
|
62 |
msgstr "Применить"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
msgid ""
|
2 |
msgstr ""
|
3 |
"Project-Id-Version: wp_translitera\n"
|
4 |
+
"POT-Creation-Date: 2017-02-12 00:09+0200\n"
|
5 |
+
"PO-Revision-Date: 2017-02-12 00:10+0200\n"
|
6 |
"Last-Translator: Evgenij Yurchenko <evgen@yur4enko.com>\n"
|
7 |
"Language-Team: \n"
|
8 |
"Language: ru_RU\n"
|
17 |
"X-Poedit-KeywordsList: __\n"
|
18 |
"X-Poedit-SearchPath-0: wp-translitera.php\n"
|
19 |
|
20 |
+
#: wp-translitera.php:109
|
21 |
msgid "Convert existing"
|
22 |
msgstr "Преобразовать существующие"
|
23 |
|
24 |
+
#: wp-translitera.php:111
|
25 |
msgid "Pages and posts"
|
26 |
msgstr "Страницы и посты"
|
27 |
|
28 |
+
#: wp-translitera.php:112
|
29 |
msgid "Headings, tags etc..."
|
30 |
msgstr "Рубрики, теги и тд"
|
31 |
|
32 |
+
#: wp-translitera.php:113
|
33 |
msgid "Transliterate"
|
34 |
msgstr "Транслитерировать"
|
35 |
|
36 |
+
#: wp-translitera.php:115 wp-translitera.php:324
|
37 |
msgid "Settings"
|
38 |
msgstr "Настройки"
|
39 |
|
40 |
+
#: wp-translitera.php:117
|
41 |
msgid "Use forces transliteration for title"
|
42 |
msgstr "Форсированный режим транслитерации"
|
43 |
|
44 |
+
#: wp-translitera.php:118
|
45 |
msgid "Transliterate names of uploads files"
|
46 |
msgstr "Транслитерировать имена загружаемых файлов"
|
47 |
|
48 |
+
#: wp-translitera.php:119
|
49 |
msgid "Transliterate 404 url"
|
50 |
msgstr "Транслитерация 404 ссылок"
|
51 |
|
52 |
+
#: wp-translitera.php:120
|
53 |
+
msgid ""
|
54 |
+
"Use transliteration in frontend for transliteration title out ACP (enable if "
|
55 |
+
"use bbPress, buddypress etc)"
|
56 |
+
msgstr ""
|
57 |
+
"Использовать транслитерацию во фронтэнде для транслитерации вне панели "
|
58 |
+
"управления (включить если используете bbPress, buddypress и др)"
|
59 |
+
|
60 |
+
#: wp-translitera.php:121
|
61 |
msgid ""
|
62 |
"File extensions, separated by commas , titles that do not need to "
|
63 |
"transliterate"
|
65 |
"Расширения файлов, разделенные запятой, заголвки которых не нужно "
|
66 |
"транслитерировать"
|
67 |
|
68 |
+
#: wp-translitera.php:122
|
69 |
msgid "Apply"
|
70 |
msgstr "Применить"
|
71 |
+
|
72 |
+
#: wp-translitera.php:220
|
73 |
+
msgid "Plugin WP Translitera has been updated,"
|
74 |
+
msgstr "Плагин WP Trandslitera был обновлен,"
|
75 |
+
|
76 |
+
#: wp-translitera.php:220
|
77 |
+
msgid "update settings"
|
78 |
+
msgstr "обновите настройки."
|
readme.txt
CHANGED
@@ -2,20 +2,24 @@
|
|
2 |
Contributors: YurchenkoEV
|
3 |
Donate link: http://yur4enko.com/
|
4 |
Tags: translate, rus-to-lat, cyr-to-lat, Seo, tag, record, page, transliterate, transliteration, bg, bulgarian
|
5 |
-
Requires at least: 3.
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag:
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
|
|
|
|
11 |
Plug-in for transliteration permanents links of records, pages, tag, media and files
|
12 |
|
13 |
== Description ==
|
14 |
-
|
|
|
15 |
Plug-in for transliteration permanents links of records, pages, tag, media and files
|
16 |
|
17 |
== Installation ==
|
18 |
-
|
|
|
19 |
Automatical from repository or unzip in plugins and activate in ACP.
|
20 |
|
21 |
== Frequently Asked Questions ==
|
@@ -24,7 +28,24 @@ Automatical from repository or unzip in plugins and activate in ACP.
|
|
24 |
|
25 |
== Changelog ==
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
= 170114 =
|
|
|
|
|
28 |
* bulgarian locale (thx for svinqvmraka) (transliteration)
|
29 |
|
30 |
= 16**** =
|
2 |
Contributors: YurchenkoEV
|
3 |
Donate link: http://yur4enko.com/
|
4 |
Tags: translate, rus-to-lat, cyr-to-lat, Seo, tag, record, page, transliterate, transliteration, bg, bulgarian
|
5 |
+
Requires at least: 3.2
|
6 |
+
Tested up to: 4.8
|
7 |
+
Stable tag: 170212
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
+
Плагин для транслитерации постоянных ссылок записей, стараниц, тегов, медиа и файлов
|
12 |
+
---
|
13 |
Plug-in for transliteration permanents links of records, pages, tag, media and files
|
14 |
|
15 |
== Description ==
|
16 |
+
Плагин для транслитерации постоянных ссылок записей, стараниц, тегов, медиа и файлов
|
17 |
+
---
|
18 |
Plug-in for transliteration permanents links of records, pages, tag, media and files
|
19 |
|
20 |
== Installation ==
|
21 |
+
Автоматичски из репозитория или распаковать в папку плагинов и активировать через панель управления
|
22 |
+
---
|
23 |
Automatical from repository or unzip in plugins and activate in ACP.
|
24 |
|
25 |
== Frequently Asked Questions ==
|
28 |
|
29 |
== Changelog ==
|
30 |
|
31 |
+
= 170212 =
|
32 |
+
* поддерка WP 3.2+ (поддержка)
|
33 |
+
* протестирован с WP 4.8 (поддержка)
|
34 |
+
* поддержка мультисайтности (ядро)
|
35 |
+
* оптимизирована работа плагина (ядро)
|
36 |
+
* добавлена ссылка на настройку из панели управления плагинами (интерфейс)
|
37 |
+
* добавлены уведомления о новом функционале и его выделение на странице плагина (интерфейс)
|
38 |
+
|
39 |
+
* support WP 3.2+ (support)
|
40 |
+
* tested with WP 4.8 (support)
|
41 |
+
* MultiSite support (core)
|
42 |
+
* optimized plugin (core)
|
43 |
+
* added settings link in plugins control panel (GUI)
|
44 |
+
* added notices about new functions and its allocation to the plugin page (GUI)
|
45 |
+
|
46 |
= 170114 =
|
47 |
+
* транслитерация болгарского (спасибо svinqvmraka) (транслитерации)
|
48 |
+
|
49 |
* bulgarian locale (thx for svinqvmraka) (transliteration)
|
50 |
|
51 |
= 16**** =
|
unistall.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php //wp=>3.2 php=>5.2.4
|
2 |
+
|
3 |
+
// Если к файлу обращаются напрямую, закроем доступ
|
4 |
+
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) )
|
5 |
+
exit();
|
6 |
+
|
7 |
+
$option_name = 'wp_translitera';
|
8 |
+
|
9 |
+
// Для обычного сайта.
|
10 |
+
if ( !is_multisite() ) {
|
11 |
+
delete_option( $option_name );
|
12 |
+
}
|
13 |
+
// Для мультисайтовой сборки.
|
14 |
+
else {
|
15 |
+
global $wpdb;
|
16 |
+
|
17 |
+
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
|
18 |
+
$original_blog_id = get_current_blog_id();
|
19 |
+
|
20 |
+
foreach ( $blog_ids as $blog_id ) {
|
21 |
+
switch_to_blog( $blog_id );
|
22 |
+
delete_site_option( $option_name );
|
23 |
+
}
|
24 |
+
|
25 |
+
switch_to_blog( $original_blog_id );
|
26 |
+
}
|
27 |
+
|
wp-translitera.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: WP Translitera
|
4 |
Plugin URI: http://yur4enko.com/category/moi-proekty/wp-translitera
|
5 |
Description: Plug-in for transliteration permanent permalink records , pages, and tag
|
6 |
-
Version:
|
7 |
Author: Evgen Yurchenko
|
8 |
Text Domain: wp_translitera
|
9 |
Domain Path: /languages/
|
@@ -27,10 +27,10 @@ Author URI: http://yur4enko.com/
|
|
27 |
Foundation, Inc.
|
28 |
*/
|
29 |
|
30 |
-
class wp_translitera {//wp=>3.
|
31 |
|
32 |
//Создаем локализации
|
33 |
-
protected static function createlocale() {//wp=>3.
|
34 |
$loc = get_locale();
|
35 |
$ret = array();
|
36 |
if ($loc == 'ru_RU') {//Русская локализация
|
@@ -91,13 +91,13 @@ class wp_translitera {//wp=>3.0 php=>5.2.4
|
|
91 |
}
|
92 |
|
93 |
//Проставляем галочки в чебоксах
|
94 |
-
protected static function getchebox($name){//wp=>
|
95 |
$value = wp_translitera::getset($name);
|
96 |
return (empty($value))?'':' checked';
|
97 |
}
|
98 |
|
99 |
//Форма админки
|
100 |
-
protected static function GetForm() {//wp=>
|
101 |
$noparsevar = wp_translitera::getset('fileext');
|
102 |
$extforform = '';
|
103 |
foreach ($noparsevar as $value) {
|
@@ -117,6 +117,7 @@ class wp_translitera {//wp=>3.0 php=>5.2.4
|
|
117 |
. '<input type="checkbox" name="use_force_transliterations" value="1"'.wp_translitera::getchebox("use_force_transliterations").'>'.__('Use forces transliteration for title','wp_translitera').'</br>'
|
118 |
. '<input type="checkbox" name="tranliterate_uploads_file" value="1"'.wp_translitera::getchebox("tranliterate_uploads_file").'>'.__('Transliterate names of uploads files','wp_translitera').'</br>'
|
119 |
. '<input type="checkbox" name="tranliterate_404" value="1"'.wp_translitera::getchebox("tranliterate_404").'>'.__('Transliterate 404 url','wp_translitera').'</br>'
|
|
|
120 |
. __('File extensions, separated by commas , titles that do not need to transliterate','wp_translitera').'<input type="text" size="80" name="typefiles" value="'.$extforform.'"></br>'
|
121 |
. '<input type="submit" value="'.__('Apply','wp_translitera').'" name="apply">'
|
122 |
. '</form>';
|
@@ -124,7 +125,7 @@ class wp_translitera {//wp=>3.0 php=>5.2.4
|
|
124 |
}
|
125 |
|
126 |
//Транслитерация в БД
|
127 |
-
protected static function
|
128 |
global $wpdb;
|
129 |
$rez = $wpdb->get_results("SELECT {$id}, {$name} FROM {$table} WHERE 1",ARRAY_A);
|
130 |
foreach ($rez as $value) {
|
@@ -136,8 +137,12 @@ class wp_translitera {//wp=>3.0 php=>5.2.4
|
|
136 |
}
|
137 |
|
138 |
//Получаем настройки
|
139 |
-
protected static function getoptions() {//wp=>3.
|
140 |
-
|
|
|
|
|
|
|
|
|
141 |
if (gettype($set) != 'array') {
|
142 |
$set = array();
|
143 |
}
|
@@ -145,47 +150,111 @@ class wp_translitera {//wp=>3.0 php=>5.2.4
|
|
145 |
}
|
146 |
|
147 |
//Получаем значение настройки
|
148 |
-
protected static function getset($name) {//wp=>
|
149 |
$set = wp_translitera::getoptions();
|
150 |
return (array_key_exists($name,$set))?$set[$name]:NULL;
|
151 |
}
|
152 |
|
153 |
-
//Записываем
|
154 |
-
protected static function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
$set = wp_translitera::getoptions();
|
156 |
$set[$name] = $value;
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
}
|
159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
//Вызываемые дочерние функции
|
|
|
|
|
|
|
|
|
|
|
161 |
//Модуль формы админки
|
162 |
-
public static function main_settings() {//wp=>3.
|
163 |
global $wpdb;
|
|
|
|
|
|
|
|
|
164 |
$act = filter_input(INPUT_POST,'transliterate');
|
165 |
if (!empty($act)) {
|
166 |
$r1 = filter_input(INPUT_POST, 'r1');
|
167 |
$r2 = filter_input(INPUT_POST, 'r2');
|
168 |
if (!empty($r1)) {
|
169 |
-
wp_translitera::
|
170 |
}
|
171 |
if (!empty($r2)){
|
172 |
-
wp_translitera::
|
173 |
}
|
174 |
|
175 |
}
|
176 |
$setupd = filter_input(INPUT_POST, 'apply');
|
|
|
177 |
if (!empty($setupd)){
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
|
|
182 |
}
|
183 |
echo wp_translitera::GetForm();
|
184 |
}
|
185 |
|
186 |
//Вызываемые функции
|
187 |
//Процедура преобразования символов
|
188 |
-
public static function transliterate($title) {//wp=>3.
|
189 |
$type = substr(filter_input(INPUT_POST, 'name'),-3);
|
190 |
if (!empty($type)) {
|
191 |
if (in_array($type, wp_translitera::getset('fileext'))) {
|
@@ -196,7 +265,7 @@ class wp_translitera {//wp=>3.0 php=>5.2.4
|
|
196 |
}
|
197 |
|
198 |
//Процедура преобразования символов форсированный режим
|
199 |
-
public static function transliterate_force($title, $raw_title) {//wp=>3.
|
200 |
$type = substr(filter_input(INPUT_POST, 'name'),-3);
|
201 |
if (!empty($type)) {
|
202 |
if (in_array($type, wp_translitera::getset('fileext'))) {
|
@@ -207,12 +276,12 @@ class wp_translitera {//wp=>3.0 php=>5.2.4
|
|
207 |
}
|
208 |
|
209 |
//Добавляем раздел в админку
|
210 |
-
public static function add_menu(){//wp=>3.
|
211 |
add_options_page('WP Translitera', 'Translitera', 'activate_plugins', __FILE__, array('wp_translitera','main_settings'));
|
212 |
}
|
213 |
|
214 |
//Попытка транслитерировать урл
|
215 |
-
public static function init404(){//wp=>
|
216 |
if (is_404()){
|
217 |
if (wp_translitera::getset('tranliterate_404')){
|
218 |
$thisurl = filter_input(INPUT_SERVER, 'REQUEST_URI');
|
@@ -226,58 +295,60 @@ class wp_translitera {//wp=>3.0 php=>5.2.4
|
|
226 |
}
|
227 |
|
228 |
//Обработка файлов загружаемых из форм
|
229 |
-
public static function rename_uploads_additional($value, $filename_raw) {//wp=>
|
230 |
if (wp_translitera::getset('tranliterate_uploads_file')){
|
231 |
$value = wp_translitera::transliterate($value);
|
232 |
}
|
233 |
return $value;
|
234 |
}
|
235 |
|
236 |
-
|
237 |
-
static function
|
238 |
-
delete_option('wp_translitera');
|
239 |
-
}
|
240 |
-
|
241 |
-
//Инициализация ядра
|
242 |
-
static function init() {//wp=>3.0 php=>5.2.4
|
243 |
-
//инициализация языка
|
244 |
-
load_plugin_textdomain('wp_translitera', false, dirname(plugin_basename(__FILE__)).'/languages');
|
245 |
-
|
246 |
-
//провека необходимости обновить БД
|
247 |
$from = wp_translitera::getset('version');
|
248 |
-
$
|
249 |
-
|
250 |
-
if (empty($from)) {
|
251 |
-
$from = 160819;
|
252 |
-
}
|
253 |
-
if ($from == 160819) {
|
254 |
-
if (wp_translitera::getset('fileext') == NULL) {
|
255 |
-
wp_translitera::updset('fileext', array());
|
256 |
-
}
|
257 |
-
$from = 161011;
|
258 |
-
}
|
259 |
-
|
260 |
-
if ($startfrom != $from) {
|
261 |
-
wp_translitera::updset('version', $from);
|
262 |
}
|
263 |
-
|
264 |
-
|
|
|
|
|
265 |
if (wp_translitera::getset('use_force_transliterations') === '1') {
|
266 |
add_filter('sanitize_title', array('wp_translitera','transliterate_force'), 25, 2);
|
267 |
} else {
|
268 |
add_filter('sanitize_title', array('wp_translitera','transliterate'), 0);
|
269 |
}
|
270 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
}
|
272 |
|
273 |
-
//wp=>3.
|
274 |
-
//Добавляем админ меню
|
275 |
-
add_action('admin_menu', array('wp_translitera', 'add_menu'));
|
276 |
//Инициализация ядра
|
277 |
add_action('init', array('wp_translitera', 'init'));
|
278 |
//Редирект 404
|
279 |
add_action('wp',array('wp_translitera','init404'));
|
280 |
//Переименовываение загружаемых файлов
|
281 |
add_filter('sanitize_file_name',array('wp_translitera', 'rename_uploads_additional'),10,2);
|
282 |
-
//Обработка удаления
|
283 |
-
register_uninstall_hook(__FILE__,array('wp_translitera','tr_delete'));
|
3 |
Plugin Name: WP Translitera
|
4 |
Plugin URI: http://yur4enko.com/category/moi-proekty/wp-translitera
|
5 |
Description: Plug-in for transliteration permanent permalink records , pages, and tag
|
6 |
+
Version: 170212
|
7 |
Author: Evgen Yurchenko
|
8 |
Text Domain: wp_translitera
|
9 |
Domain Path: /languages/
|
27 |
Foundation, Inc.
|
28 |
*/
|
29 |
|
30 |
+
class wp_translitera {//wp=>3.2 php=>5.2.4
|
31 |
|
32 |
//Создаем локализации
|
33 |
+
protected static function createlocale() {//wp=>3.2 php=>5.2.4
|
34 |
$loc = get_locale();
|
35 |
$ret = array();
|
36 |
if ($loc == 'ru_RU') {//Русская локализация
|
91 |
}
|
92 |
|
93 |
//Проставляем галочки в чебоксах
|
94 |
+
protected static function getchebox($name){//wp=>3.2 php=>5.2.4
|
95 |
$value = wp_translitera::getset($name);
|
96 |
return (empty($value))?'':' checked';
|
97 |
}
|
98 |
|
99 |
//Форма админки
|
100 |
+
protected static function GetForm() {//wp=>3.2 php=>5.2.4
|
101 |
$noparsevar = wp_translitera::getset('fileext');
|
102 |
$extforform = '';
|
103 |
foreach ($noparsevar as $value) {
|
117 |
. '<input type="checkbox" name="use_force_transliterations" value="1"'.wp_translitera::getchebox("use_force_transliterations").'>'.__('Use forces transliteration for title','wp_translitera').'</br>'
|
118 |
. '<input type="checkbox" name="tranliterate_uploads_file" value="1"'.wp_translitera::getchebox("tranliterate_uploads_file").'>'.__('Transliterate names of uploads files','wp_translitera').'</br>'
|
119 |
. '<input type="checkbox" name="tranliterate_404" value="1"'.wp_translitera::getchebox("tranliterate_404").'>'.__('Transliterate 404 url','wp_translitera').'</br>'
|
120 |
+
. '<input type="checkbox" name="init_in_front" value="1"'.wp_translitera::getchebox("init_in_front").'><span style="font-weight:bold;color:red">'.__('Use transliteration in frontend for transliteration title out ACP (enable if use bbPress, buddypress etc)','wp_translitera').'</span></br>'
|
121 |
. __('File extensions, separated by commas , titles that do not need to transliterate','wp_translitera').'<input type="text" size="80" name="typefiles" value="'.$extforform.'"></br>'
|
122 |
. '<input type="submit" value="'.__('Apply','wp_translitera').'" name="apply">'
|
123 |
. '</form>';
|
125 |
}
|
126 |
|
127 |
//Транслитерация в БД
|
128 |
+
protected static function do_transliterate($table,$id,$name) {//wp=>3.2 php=>5.2.4
|
129 |
global $wpdb;
|
130 |
$rez = $wpdb->get_results("SELECT {$id}, {$name} FROM {$table} WHERE 1",ARRAY_A);
|
131 |
foreach ($rez as $value) {
|
137 |
}
|
138 |
|
139 |
//Получаем настройки
|
140 |
+
protected static function getoptions() {//wp=>3.2 php=>5.2.4
|
141 |
+
if (is_multisite()) {
|
142 |
+
$set = get_site_option('wp_translitera');
|
143 |
+
} else {
|
144 |
+
$set = get_option('wp_translitera');
|
145 |
+
}
|
146 |
if (gettype($set) != 'array') {
|
147 |
$set = array();
|
148 |
}
|
150 |
}
|
151 |
|
152 |
//Получаем значение настройки
|
153 |
+
protected static function getset($name) {//wp=>3.2 php=>5.2.4
|
154 |
$set = wp_translitera::getoptions();
|
155 |
return (array_key_exists($name,$set))?$set[$name]:NULL;
|
156 |
}
|
157 |
|
158 |
+
//Записываем опцию
|
159 |
+
protected static function updateoption($set) {//wp=>3.2 php=>5.2.4
|
160 |
+
if (is_multisite()) {
|
161 |
+
update_site_option('wp_translitera',$set);
|
162 |
+
} else {
|
163 |
+
update_option('wp_translitera',$set);
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
//Записываем настройку
|
168 |
+
protected static function updset($name,$value) {//wp=>3.2 php=>5.2.4
|
169 |
$set = wp_translitera::getoptions();
|
170 |
$set[$name] = $value;
|
171 |
+
wp_translitera::updateoption($set);
|
172 |
+
}
|
173 |
+
|
174 |
+
//Записываем настройки
|
175 |
+
protected static function updsets($sets) {//wp=>3.2 php=>5.2.4
|
176 |
+
if (gettype($sets) != 'array') {
|
177 |
+
$sets = array();
|
178 |
+
}
|
179 |
+
$set = $sets + wp_translitera::getoptions();
|
180 |
+
wp_translitera::updateoption($set);
|
181 |
}
|
182 |
|
183 |
+
//Обнволение БД
|
184 |
+
protected static function update_bd($from) {//wp=>3.2 php=>5.2.4
|
185 |
+
if (empty($from)) {
|
186 |
+
$from = 160819;
|
187 |
+
}
|
188 |
+
if ($from == 160819) {
|
189 |
+
if (wp_translitera::getset('fileext') == NULL) {
|
190 |
+
wp_translitera::updset('fileext', array());
|
191 |
+
}
|
192 |
+
$from = 161011;
|
193 |
+
}
|
194 |
+
if ($from = 161011) {
|
195 |
+
if (is_multisite()) {
|
196 |
+
$set = wp_translitera::getoptions();
|
197 |
+
global $wpdb;
|
198 |
+
|
199 |
+
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
|
200 |
+
$original_blog_id = get_current_blog_id();
|
201 |
+
|
202 |
+
foreach ( $blog_ids as $blog_id ) {
|
203 |
+
switch_to_blog( $blog_id );
|
204 |
+
update_site_option('wp_translitera',$set);
|
205 |
+
}
|
206 |
+
|
207 |
+
switch_to_blog( $original_blog_id );
|
208 |
+
}
|
209 |
+
|
210 |
+
add_action('admin_notices',array('wp_translitera','notice_admin_plugin_updated'));
|
211 |
+
$from = 170212;
|
212 |
+
}
|
213 |
+
|
214 |
+
wp_translitera::updset('version', $from);
|
215 |
+
}
|
216 |
+
|
217 |
//Вызываемые дочерние функции
|
218 |
+
//Уведомление о необходимости проверить настройки
|
219 |
+
static function notice_admin_plugin_updated() {
|
220 |
+
echo '<div class="updated" style="padding-top: 15px; padding-bottom:15px">'.__('Plugin WP Translitera has been updated,','wp_translitera').' <a href="options-general.php?page=wp-translitera%2Fwp-translitera">'.__('update settings','wp_translitera').'</a></div>';
|
221 |
+
}
|
222 |
+
|
223 |
//Модуль формы админки
|
224 |
+
public static function main_settings() {//wp=>3.2 php=>5.2.4
|
225 |
global $wpdb;
|
226 |
+
|
227 |
+
//инициализация языка
|
228 |
+
load_plugin_textdomain('wp_translitera', false, dirname(plugin_basename(__FILE__)).'/languages');
|
229 |
+
|
230 |
$act = filter_input(INPUT_POST,'transliterate');
|
231 |
if (!empty($act)) {
|
232 |
$r1 = filter_input(INPUT_POST, 'r1');
|
233 |
$r2 = filter_input(INPUT_POST, 'r2');
|
234 |
if (!empty($r1)) {
|
235 |
+
wp_translitera::do_transliterate($wpdb->posts, 'ID', 'post_name');
|
236 |
}
|
237 |
if (!empty($r2)){
|
238 |
+
wp_translitera::do_transliterate($wpdb->terms, 'term_id', 'slug');
|
239 |
}
|
240 |
|
241 |
}
|
242 |
$setupd = filter_input(INPUT_POST, 'apply');
|
243 |
+
$sets = array();
|
244 |
if (!empty($setupd)){
|
245 |
+
$sets['tranliterate_uploads_file'] = filter_input(INPUT_POST,'tranliterate_uploads_file');
|
246 |
+
$sets['tranliterate_404'] = filter_input(INPUT_POST,'tranliterate_404');
|
247 |
+
$sets['fileext'] = explode(',', filter_input(INPUT_POST, 'typefiles'));
|
248 |
+
$sets['use_force_transliterations'] = filter_input(INPUT_POST, 'use_force_transliterations');
|
249 |
+
$sets['use_force_transliterations'] = filter_input(INPUT_POST, 'init_in_front');
|
250 |
+
wp_translitera::updsets($sets);
|
251 |
}
|
252 |
echo wp_translitera::GetForm();
|
253 |
}
|
254 |
|
255 |
//Вызываемые функции
|
256 |
//Процедура преобразования символов
|
257 |
+
public static function transliterate($title) {//wp=>3.2 php=>5.2.4
|
258 |
$type = substr(filter_input(INPUT_POST, 'name'),-3);
|
259 |
if (!empty($type)) {
|
260 |
if (in_array($type, wp_translitera::getset('fileext'))) {
|
265 |
}
|
266 |
|
267 |
//Процедура преобразования символов форсированный режим
|
268 |
+
public static function transliterate_force($title, $raw_title) {//wp=>3.2 php=>5.2.4
|
269 |
$type = substr(filter_input(INPUT_POST, 'name'),-3);
|
270 |
if (!empty($type)) {
|
271 |
if (in_array($type, wp_translitera::getset('fileext'))) {
|
276 |
}
|
277 |
|
278 |
//Добавляем раздел в админку
|
279 |
+
public static function add_menu(){//wp=>3.2 php=>5.2.4
|
280 |
add_options_page('WP Translitera', 'Translitera', 'activate_plugins', __FILE__, array('wp_translitera','main_settings'));
|
281 |
}
|
282 |
|
283 |
//Попытка транслитерировать урл
|
284 |
+
public static function init404(){//wp=>3.2 php=>5.2.4
|
285 |
if (is_404()){
|
286 |
if (wp_translitera::getset('tranliterate_404')){
|
287 |
$thisurl = filter_input(INPUT_SERVER, 'REQUEST_URI');
|
295 |
}
|
296 |
|
297 |
//Обработка файлов загружаемых из форм
|
298 |
+
public static function rename_uploads_additional($value, $filename_raw) {//wp=>3.2 php=>5.2.4
|
299 |
if (wp_translitera::getset('tranliterate_uploads_file')){
|
300 |
$value = wp_translitera::transliterate($value);
|
301 |
}
|
302 |
return $value;
|
303 |
}
|
304 |
|
305 |
+
//провека необходимости обновить БД
|
306 |
+
static function needupdate() {//wp=>3.2 php=>5.2.4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
307 |
$from = wp_translitera::getset('version');
|
308 |
+
if ($from != 170212) {
|
309 |
+
wp_translitera::update_bd($from);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
310 |
}
|
311 |
+
}
|
312 |
+
|
313 |
+
//инициализация метода транслитерации
|
314 |
+
static function prepare_transliterate() {//wp=>3.2 php=>5.2.4
|
315 |
if (wp_translitera::getset('use_force_transliterations') === '1') {
|
316 |
add_filter('sanitize_title', array('wp_translitera','transliterate_force'), 25, 2);
|
317 |
} else {
|
318 |
add_filter('sanitize_title', array('wp_translitera','transliterate'), 0);
|
319 |
}
|
320 |
}
|
321 |
+
|
322 |
+
//Добавляем ссылку на страницу настроек
|
323 |
+
static function add_plugin_settings_link($links) {//wp=>3.2 php=>5.2.4
|
324 |
+
$addlink['settings'] = '<a href="options-general.php?page=wp-translitera%2Fwp-translitera">'.__('Settings','wp_translitera').'</a>';
|
325 |
+
$links = $addlink + $links;
|
326 |
+
return $links;
|
327 |
+
}
|
328 |
+
|
329 |
+
//Инициализация ядра
|
330 |
+
static function init() {//wp=>3.2 php=>5.2.4
|
331 |
+
//Проверка необходимости обновить БД
|
332 |
+
add_action('admin_init', array('wp_translitera', 'needupdate'));
|
333 |
+
|
334 |
+
//Добавляем админ меню и ссылку настроек
|
335 |
+
add_action('admin_menu', array('wp_translitera', 'add_menu'));
|
336 |
+
$plugin_file = plugin_basename(__FILE__);
|
337 |
+
add_filter("plugin_action_links_$plugin_file",array('wp_translitera','add_plugin_settings_link'));
|
338 |
+
|
339 |
+
//Инициализировать только для админки или везде
|
340 |
+
if (wp_translitera::getset('init_in_front') === '1') {
|
341 |
+
wp_translitera::prepare_transliterate();
|
342 |
+
} else {
|
343 |
+
add_action('admin_init',array('wp_translitera', 'prepare_transliterate'));
|
344 |
+
}
|
345 |
+
}
|
346 |
}
|
347 |
|
348 |
+
//wp=>3.2 php=>5.2.4
|
|
|
|
|
349 |
//Инициализация ядра
|
350 |
add_action('init', array('wp_translitera', 'init'));
|
351 |
//Редирект 404
|
352 |
add_action('wp',array('wp_translitera','init404'));
|
353 |
//Переименовываение загружаемых файлов
|
354 |
add_filter('sanitize_file_name',array('wp_translitera', 'rename_uploads_additional'),10,2);
|
|
|
|