Version Description
- Remove old functions (core)
- Added curent version (db)
- Added update functions (core)
- Security fix (core)
- Tested whith Wordpress 4.6 release and Wordpress 4.7alpha
Download this release
Release Info
Developer | YurchenkoEV |
Plugin | WP Translitera |
Version | 160819 |
Comparing to | |
See all releases |
Code changes from version 160707 to 160819
- readme.txt +9 -2
- wp-translitera.php +66 -52
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: YurchenkoEV
|
|
3 |
Donate link: http://yur4enko.com/
|
4 |
Tags: translate, rus-to-lat, Seo, tag, record, page, transliterate, transliteration
|
5 |
Requires at least: 3.0
|
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 |
|
@@ -24,6 +24,13 @@ Automatical from repository or unzip in plugins and activate in ACP.
|
|
24 |
|
25 |
== Changelog ==
|
26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
= 160707 =
|
28 |
* Added transliterate request url for redirect old permalink
|
29 |
|
3 |
Donate link: http://yur4enko.com/
|
4 |
Tags: translate, rus-to-lat, Seo, tag, record, page, transliterate, transliteration
|
5 |
Requires at least: 3.0
|
6 |
+
Tested up to: 4.7
|
7 |
+
Stable tag: 160819
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
24 |
|
25 |
== Changelog ==
|
26 |
|
27 |
+
= 160819 =
|
28 |
+
* Remove old functions (core)
|
29 |
+
* Added curent version (db)
|
30 |
+
* Added update functions (core)
|
31 |
+
* Security fix (core)
|
32 |
+
* Tested whith Wordpress 4.6 release and Wordpress 4.7alpha
|
33 |
+
|
34 |
= 160707 =
|
35 |
* Added transliterate request url for redirect old permalink
|
36 |
|
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/
|
@@ -75,25 +75,23 @@ class wp_translitera {//wp=>3.0 php=>5.2.4
|
|
75 |
}
|
76 |
return $ret;
|
77 |
}
|
78 |
-
|
79 |
-
//Процедура преобразования символов
|
80 |
-
public static function transliterate($title) {//wp=>0.0.0 php=>5.2.4
|
81 |
-
return strtr($title, wp_translitera::createlocale());
|
82 |
-
}
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
87 |
}
|
88 |
|
89 |
//Проставляем галочки в чебоксах
|
90 |
-
|
91 |
$value = wp_translitera::getset($name);
|
92 |
return (empty($value))?'':' checked';
|
93 |
}
|
94 |
|
95 |
//Форма админки
|
96 |
-
|
97 |
$ret = '<h2>'.__('Convert existing','wp_translitera').':</h2></br>'
|
98 |
. '<form method=POST> '
|
99 |
. '<input type="checkbox" name="r1" value="1">'.__('Pages and posts','wp_translitera').'</br>'
|
@@ -108,7 +106,7 @@ class wp_translitera {//wp=>3.0 php=>5.2.4
|
|
108 |
}
|
109 |
|
110 |
//Транслитерация в БД
|
111 |
-
|
112 |
global $wpdb;
|
113 |
$rez = $wpdb->get_results("SELECT {$id}, {$name} FROM {$table} WHERE 1",ARRAY_A);
|
114 |
foreach ($rez as $value) {
|
@@ -119,6 +117,29 @@ class wp_translitera {//wp=>3.0 php=>5.2.4
|
|
119 |
}
|
120 |
}
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
//Модуль формы админки
|
123 |
public static function main_settings() {//wp=>3.0 php=>5.2.4
|
124 |
global $wpdb;
|
@@ -142,52 +163,30 @@ class wp_translitera {//wp=>3.0 php=>5.2.4
|
|
142 |
echo wp_translitera::GetForm();
|
143 |
}
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
//Получаем настройки
|
151 |
-
public static function getoptions() {//wp=>3.0 php=>5.2.4
|
152 |
-
$set = get_option('wp_translitera');
|
153 |
-
if (gettype($set) != 'array') {
|
154 |
-
$set = array();
|
155 |
-
}
|
156 |
-
return $set;
|
157 |
-
}
|
158 |
-
|
159 |
-
//Получаем значение настройки
|
160 |
-
public static function getset($name) {//wp=>0.0.0 php=>5.2.4
|
161 |
-
$set = wp_translitera::getoptions();
|
162 |
-
return (array_key_exists($name,$set))?$set[$name]:NULL;
|
163 |
-
}
|
164 |
-
|
165 |
-
//Записываем настройки
|
166 |
-
public static function updset($name,$value) {//wp=>3.0 php=>5.2.4
|
167 |
-
$set = wp_translitera::getoptions();
|
168 |
-
$set[$name] = $value;
|
169 |
-
update_option('wp_translitera',$set);
|
170 |
}
|
171 |
|
172 |
-
|
173 |
-
static function
|
174 |
-
|
175 |
}
|
176 |
|
177 |
-
|
178 |
-
public static function
|
179 |
-
|
180 |
-
$value['name'] = wp_translitera::transliterate($value['name']);
|
181 |
-
}
|
182 |
-
return $value;
|
183 |
}
|
184 |
|
185 |
-
|
186 |
-
public static function
|
187 |
-
|
188 |
-
|
|
|
|
|
|
|
189 |
}
|
190 |
-
return $value;
|
191 |
}
|
192 |
|
193 |
//Попытка транслитерировать урл
|
@@ -203,6 +202,19 @@ class wp_translitera {//wp=>3.0 php=>5.2.4
|
|
203 |
}
|
204 |
}
|
205 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
}
|
207 |
|
208 |
//wp=>3.0 php=>5.2.4
|
@@ -212,9 +224,11 @@ add_action('sanitize_title', array('wp_translitera','transliterate'), 0);
|
|
212 |
add_action('admin_menu', array('wp_translitera', 'add_menu'));
|
213 |
//Загружка языковой поддержки
|
214 |
add_action('init', array('wp_translitera', 'initlang'));
|
|
|
|
|
215 |
//Редирект 404
|
216 |
add_action('wp',array('wp_translitera','init404'));
|
217 |
//Переименовываение загружаемых файлов
|
218 |
add_filter('sanitize_file_name',array('wp_translitera', 'rename_uploads_additional'),10,2);
|
219 |
//Обработка удаления
|
220 |
-
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: 160819
|
7 |
Author: Evgen Yurchenko
|
8 |
Text Domain: wp_translitera
|
9 |
Domain Path: /languages/
|
75 |
}
|
76 |
return $ret;
|
77 |
}
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
+
//Обработка обновления
|
80 |
+
protected static function do_update($from) {
|
81 |
+
if (empty($from)) {
|
82 |
+
wp_translitera::updset('version', 160819);
|
83 |
+
$from = 160819;
|
84 |
+
}
|
85 |
}
|
86 |
|
87 |
//Проставляем галочки в чебоксах
|
88 |
+
protected static function getchebox($name){//wp=>0.0.0 php=>5.2.4
|
89 |
$value = wp_translitera::getset($name);
|
90 |
return (empty($value))?'':' checked';
|
91 |
}
|
92 |
|
93 |
//Форма админки
|
94 |
+
protected static function GetForm() {//wp=>0.0.0 php=>5.2.4
|
95 |
$ret = '<h2>'.__('Convert existing','wp_translitera').':</h2></br>'
|
96 |
. '<form method=POST> '
|
97 |
. '<input type="checkbox" name="r1" value="1">'.__('Pages and posts','wp_translitera').'</br>'
|
106 |
}
|
107 |
|
108 |
//Транслитерация в БД
|
109 |
+
protected static function do_transliterte($table,$id,$name) {//wp=>3.0 php=>5.2.4
|
110 |
global $wpdb;
|
111 |
$rez = $wpdb->get_results("SELECT {$id}, {$name} FROM {$table} WHERE 1",ARRAY_A);
|
112 |
foreach ($rez as $value) {
|
117 |
}
|
118 |
}
|
119 |
|
120 |
+
//Получаем настройки
|
121 |
+
protected static function getoptions() {//wp=>3.0 php=>5.2.4
|
122 |
+
$set = get_option('wp_translitera');
|
123 |
+
if (gettype($set) != 'array') {
|
124 |
+
$set = array();
|
125 |
+
}
|
126 |
+
return $set;
|
127 |
+
}
|
128 |
+
|
129 |
+
//Получаем значение настройки
|
130 |
+
protected static function getset($name) {//wp=>0.0.0 php=>5.2.4
|
131 |
+
$set = wp_translitera::getoptions();
|
132 |
+
return (array_key_exists($name,$set))?$set[$name]:NULL;
|
133 |
+
}
|
134 |
+
|
135 |
+
//Записываем настройки
|
136 |
+
protected static function updset($name,$value) {//wp=>3.0 php=>5.2.4
|
137 |
+
$set = wp_translitera::getoptions();
|
138 |
+
$set[$name] = $value;
|
139 |
+
update_option('wp_translitera',$set);
|
140 |
+
}
|
141 |
+
|
142 |
+
//Вызываемые дочерние функции
|
143 |
//Модуль формы админки
|
144 |
public static function main_settings() {//wp=>3.0 php=>5.2.4
|
145 |
global $wpdb;
|
163 |
echo wp_translitera::GetForm();
|
164 |
}
|
165 |
|
166 |
+
//Вызываемые функции
|
167 |
+
//Процедура преобразования символов
|
168 |
+
public static function transliterate($title) {//wp=>0.0.0 php=>5.2.4
|
169 |
+
return strtr($title, wp_translitera::createlocale());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
}
|
171 |
|
172 |
+
//Добавляем раздел в админку
|
173 |
+
public static function add_menu(){//wp=>3.0 php=>5.2.4
|
174 |
+
add_options_page('WP Translitera', 'Translitera', 'activate_plugins', __FILE__, array('wp_translitera','main_settings'));
|
175 |
}
|
176 |
|
177 |
+
//Инициализация языка
|
178 |
+
public static function initlang() {//wp=>3.0 php=>5.2.4
|
179 |
+
load_plugin_textdomain('wp_translitera', false, dirname(plugin_basename(__FILE__)).'/languages');
|
|
|
|
|
|
|
180 |
}
|
181 |
|
182 |
+
//Обновление системы
|
183 |
+
public static function needupd($param) {//wp=>3.0 php=>5.2.4
|
184 |
+
$thisversion = 160819;
|
185 |
+
$curentversion = wp_translitera::getset('version');
|
186 |
+
|
187 |
+
if ($thisversion != $curentversion){
|
188 |
+
wp_translitera::do_update($curentversion);
|
189 |
}
|
|
|
190 |
}
|
191 |
|
192 |
//Попытка транслитерировать урл
|
202 |
}
|
203 |
}
|
204 |
}
|
205 |
+
|
206 |
+
//Обработка файлов загружаемых из форм
|
207 |
+
public static function rename_uploads_additional($value, $filename_raw) {//wp=>0.0.0 php=>5.2.4
|
208 |
+
if (wp_translitera::getset('tranliterate_uploads_file')){
|
209 |
+
$value = wp_translitera::transliterate($value);
|
210 |
+
}
|
211 |
+
return $value;
|
212 |
+
}
|
213 |
+
|
214 |
+
//Чистка при удалении
|
215 |
+
static function tr_delete(){//wp=>3.0 php=>5.2.4
|
216 |
+
delete_option('wp_translitera');
|
217 |
+
}
|
218 |
}
|
219 |
|
220 |
//wp=>3.0 php=>5.2.4
|
224 |
add_action('admin_menu', array('wp_translitera', 'add_menu'));
|
225 |
//Загружка языковой поддержки
|
226 |
add_action('init', array('wp_translitera', 'initlang'));
|
227 |
+
//Проверка обновления
|
228 |
+
add_action('init', array('wp_translitera', 'needupd'));
|
229 |
//Редирект 404
|
230 |
add_action('wp',array('wp_translitera','init404'));
|
231 |
//Переименовываение загружаемых файлов
|
232 |
add_filter('sanitize_file_name',array('wp_translitera', 'rename_uploads_additional'),10,2);
|
233 |
//Обработка удаления
|
234 |
+
register_uninstall_hook(__FILE__,array('wp_translitera','tr_delete'));
|