Uptolike Social Share Buttons - Version 1.4.7

Version Description



  • data-url

=

Download this release

Release Info

Developer na1vez
Plugin Icon 128x128 Uptolike Social Share Buttons
Version 1.4.7
Comparing to
See all releases

Code changes from version 1.4.6 to 1.4.7

api_functions.php CHANGED
@@ -6,22 +6,20 @@ const HOST = 'https://uptolike.com/';
6
  /**
7
  * @param $email
8
  * @param $partnerId 'cms' for cms modules
9
- * @param $projectId 'cms'.site name
 
10
  * @return bool|string 'if false - somthing wrong, if string - it's cryptkey'
11
  */
12
- function userReg($email, $partnerId, $projectId){
13
 
14
  if ($email !== '' && $partnerId !== '' && $projectId !== '') {
15
- $url = 'https://uptolike.com/api/getCryptKeyWithUserReg.json?'.http_build_query(array(
16
- 'email' => $email,
17
- 'partner' => $partnerId,
18
- 'projectId' => $projectId));
19
 
20
  $jsonAnswer = file_get_contents($url);
21
  if (false !== $jsonAnswer) {
22
  $answer = json_decode($jsonAnswer);
23
  return $answer->cryptKey;
24
- } else return $jsonAnswer;
25
 
26
  } else return 'one of params is empty';
27
  }
@@ -32,14 +30,11 @@ function userReg($email, $partnerId, $projectId){
32
  * @param $cryptKey String
33
  */
34
  function statIframe($partnerId, $mail, $cryptKey) {
35
- $params = array(
36
- 'mail' => $mail,
37
- 'partner' => $partnerId
38
- );
39
- $paramsStr = 'mail='.$mail.'&partner='.$partnerId;
40
- $signature = md5($paramsStr.$cryptKey);
41
  $params['signature'] = $signature;
42
- $finalUrl = 'https://uptolike.com/api/statistics.html?'.http_build_query($params);
43
 
44
  return $finalUrl;
45
  }
@@ -49,20 +44,17 @@ function statIframe($partnerId, $mail, $cryptKey) {
49
  * @param $partnerId 'cms' for cms sites
50
  * @param $projectId 'cms'.site_name
51
  * @param $cryptKey crypt key, received from server
 
52
  * @return string
53
  */
54
  function constructorIframe($mail, $partnerId, $projectId, $cryptKey) {
55
 
56
- $params = array ('mail' => $mail,
57
- 'partner' => $partnerId,
58
- 'projectId' => $projectId);
59
 
60
- $paramsStr = 'mail='.$mail.'&partner='.$partnerId.'&projectId='.$projectId.$cryptKey;
61
  $signature = md5($paramsStr);
62
  $params['signature'] = $signature;
63
- $finalUrl = 'https://uptolike.com/api/constructor.html?'.http_build_query($params);
64
 
65
  return $finalUrl;
66
  }
67
-
68
-
6
  /**
7
  * @param $email
8
  * @param $partnerId 'cms' for cms modules
9
+ * @param $projectId 'cms'.site name
10
+ *
11
  * @return bool|string 'if false - somthing wrong, if string - it's cryptkey'
12
  */
13
+ function userReg($email, $partnerId, $projectId) {
14
 
15
  if ($email !== '' && $partnerId !== '' && $projectId !== '') {
16
+ $url = 'https://uptolike.com/api/getCryptKeyWithUserReg.json?' . http_build_query(array('email' => $email, 'partner' => $partnerId, 'projectId' => $projectId));
 
 
 
17
 
18
  $jsonAnswer = file_get_contents($url);
19
  if (false !== $jsonAnswer) {
20
  $answer = json_decode($jsonAnswer);
21
  return $answer->cryptKey;
22
+ } else return $jsonAnswer;
23
 
24
  } else return 'one of params is empty';
25
  }
30
  * @param $cryptKey String
31
  */
32
  function statIframe($partnerId, $mail, $cryptKey) {
33
+ $params = array('mail' => $mail, 'partner' => $partnerId);
34
+ $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId;
35
+ $signature = md5($paramsStr . $cryptKey);
 
 
 
36
  $params['signature'] = $signature;
37
+ $finalUrl = 'https://uptolike.com/api/statistics.html?' . http_build_query($params);
38
 
39
  return $finalUrl;
40
  }
44
  * @param $partnerId 'cms' for cms sites
45
  * @param $projectId 'cms'.site_name
46
  * @param $cryptKey crypt key, received from server
47
+ *
48
  * @return string
49
  */
50
  function constructorIframe($mail, $partnerId, $projectId, $cryptKey) {
51
 
52
+ $params = array('mail' => $mail, 'partner' => $partnerId, 'projectId' => $projectId);
 
 
53
 
54
+ $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId . '&projectId=' . $projectId . $cryptKey;
55
  $signature = md5($paramsStr);
56
  $params['signature'] = $signature;
57
+ $finalUrl = 'https://uptolike.com/api/constructor.html?' . http_build_query($params);
58
 
59
  return $finalUrl;
60
  }
 
 
uptolike_style.css → css/uptolike_style.css RENAMED
@@ -1,5 +1,3 @@
1
- /* 1.4.6 26/02/16 */
2
-
3
  .id_number {
4
  width: 520px;
5
  }
@@ -87,7 +85,7 @@ iframe#stats_iframe {
87
  }
88
 
89
  .utl_logo {
90
- background-image: url('/wp-content/plugins/uptolike-share/plg_icons.png');
91
  width: 50px;
92
  height: 50px;
93
  margin-left: 17px;
 
 
1
  .id_number {
2
  width: 520px;
3
  }
85
  }
86
 
87
  .utl_logo {
88
+ background-image: url('/wp-content/plugins/uptolike-share/images/plg_icons.png');
89
  width: 50px;
90
  height: 50px;
91
  margin-left: 17px;
logo-small.png → images/logo-small.png RENAMED
File without changes
plg_icons.png → images/plg_icons.png RENAMED
File without changes
quest.png → images/quest.png RENAMED
File without changes
main.js → js/main.js RENAMED
File without changes
readme.txt CHANGED
@@ -1,210 +1,219 @@
1
- === Uptolike Social Share Buttons ===
2
- Tags: +1, UpToLike, AddThis, social buttons, bookmark, bookmarking, like, share, share button, sharing, social bookmarking, social bookmarks, social buttons, кнопки соцсетей, социальные кнопки
3
- Requires at least: 3.0.1
4
- Tested up to: 4.4.2
5
- Stable tag: 1.4.6
6
-
7
- Uptolike Social Share Buttons - social bookmarking widget with sharing statistics.
8
-
9
- == Description ==
10
-
11
- **What Can You Do With UpToLike Social Share Buttons?**
12
-
13
- * Create custom buttons that will visually appeal to users
14
- * Easily manage social activity online
15
- * Increase online engagement through Shares and Likes
16
- * Attract new visitors from social networks
17
- * Collect and analyze the social activity of users
18
- * Adjust content strategy based on analytics
19
-
20
- UpToLike is a single interface from which you can manage the appearance and efficiency of social buttons on your site, as well as collect and analyze statistics on
21
- likes, shares, returns, new users, sources of social traffic, and more.
22
-
23
- **Which social networks does UpToLike Social Share Buttons support?**
24
-
25
- UpToLike is compatible with 25 popular social networking sites. It supports the following functions: Bookmark, Print, Email, Follow, etc.
26
-
27
- **Unique Functions of UpToLike Social Share Buttons**
28
-
29
- * Customization of social buttons:
30
- 1. 3 different shapes
31
- 2. 3 sizes
32
- 3. Hover effect (increase, clockwise rotation)
33
- 4. 14 button styles
34
- 5. Button background
35
- 6. Text color
36
- 7. Text size of the counter
37
-
38
- * Social Media Following
39
- * Automatic text selection: the system gives you the option to share a highlighted piece of text on a social network
40
- * Gathering unique statistics of social media activity
41
-
42
- **What statistics does UpToLike collect?**
43
-
44
- * Number of Likes and Shares on site during the selected period
45
- * Number of users attracted because of Likes and Shares
46
- * Separation of traffic on social networks
47
- * Per-page site activity: how many Likes and Shares for each individual page, and how many new visitors came to each page
48
- * Social buttons adapted to mobile devices
49
-
50
- **Uptolike Social Share Buttons - бесплатный русскоязычный плагин социальных кнопок**
51
-
52
- **Какие задачи выполняет плагин Uptolike?**
53
-
54
- * Установить на сайте красивые, полностью кастомизрованные социальные кнопки, которые будут нравиться пользователям
55
- * Управлять социальной активностью пользователей на сайте
56
- * Увеличивать показатель шаринга на сайте
57
- * Привлекать новых посетителей из социальных сетей
58
- * Собирать и анализировать статистику социальной активности пользователей
59
- * Корректировать контент-стратегию
60
-
61
- Uptolike – единый интерфейс, откуда можно управлять эффективностью социальных кнопок на сайте, а также собирать и анализировать статистику по лайкам, шарам, количеству возвратов, количеству привлеченных новых пользователей, источниках социального трафика и так далее.
62
-
63
- **Какие социальные сети поддерживает Uptolike?**
64
-
65
- Uptolike поддерживает 25 популярных социальных сетей: Вконтакте, Facebook, Одноклассники, Twitter, и т.д.
66
-
67
- **Уникальные фишки Uptolike**
68
-
69
- * Полная кастомизация социальных кнопок:
70
- 1. 3 формы
71
- 2. 3 размера
72
- 3. эффект при наведении (увеличение, поворот по часовой стрелке)
73
- 4. 14 стилей кнопок
74
- 5. настройка фона кнопок
75
- 6. выбор цвета текста
76
- 7. установка размера текста счётчика
77
-
78
- * Функция фолловинга
79
- * Функция цитирования по тексту – выделенный участок текста автоматически предлагается расшарить в социальной сети
80
- * Уникальная статистика социальной активности на сайте
81
- * Кнопки социальных сетей, адаптированные под мобильные устройства
82
-
83
- **Статистика, которую собирает Uptolike**
84
-
85
- * Количество лайков и шаров на сайте за выбранный период
86
- * Количество привлеченных пользователей, благодаря лайкам и шарам
87
- * Разделение трафика по социальным сетям
88
- * Постраничная статистика по сайту: сколько лайков и шаров получила каждая отдельная. страница сайта, и сколько новых посетителей пришли именно на эту страницу
89
-
90
- == Installation ==
91
- 1. Go to Plugins -> Add New
92
- 2. Search for Uptolike
93
- 3. Install the plugin called *Uptolike Social Share Buttons* and activate it
94
- 4. Adjust your settings
95
- 5. Request and fill the secret key field, if you want to receive the statistics
96
- 6. Enjoy!
97
-
98
- ***
99
-
100
- 1. Выберите Плагины -> Добавить новый
101
- 2. В строке поиска введите Uptolike
102
- 3. Установите плагин *Uptolike Social Share Buttons* и активируйте
103
- 4. Настройте внешний вид кнопок
104
- 5. Для отображения статистики получите на адресс электронной почты секретный ключ и введите его на странице Статистика
105
- 6. Наслаждайтесь!
106
-
107
- == Frequently Asked Questions ==
108
- Answers to Frequently Asked Questions you can find at http://uptolike.ru/faq
109
-
110
- ***
111
-
112
- Ответы на часто задаваемые вопросы вы можете найти на http://uptolike.ru/faq
113
-
114
- == Screenshots ==
115
- 1. Customizing sharing buttons
116
- 2. Buttons appearance
117
- 3. Traffic and sharing statistics
118
-
119
- == Changelog ==
120
- = 1.4.6 =
121
- * Исправлено корректное отображение виджета на главной странице
122
-
123
- = 1.4.5 =
124
- * Code refactor
125
- * Minor fix
126
-
127
- = 1.4.4 =
128
- * Bug fix
129
-
130
- = 1.4.3 =
131
- * Bug fix
132
-
133
- = 1.4.2 =
134
- * Bug fix
135
- * Enhancement: rename
136
-
137
- = 1.4.1 =
138
- * Enhancement: settings
139
-
140
- = 1.4.0 =
141
- * Bug fix
142
-
143
- = 1.3.9 =
144
- * Enhancement: settings
145
-
146
- = 1.3.8 =
147
- * Enhancement: new control panel
148
- * Bug fix
149
-
150
- = 1.3.7 =
151
- * Enhancement: security
152
-
153
- = 1.3.6 =
154
- * Bug fix
155
-
156
- = 1.3.5 =
157
- * Enhancement: new align and shortcode settings
158
-
159
- = 1.3.4 =
160
- * Bug fix
161
-
162
- = 1.3.3 =
163
- * Enhancement
164
-
165
- = 1.3.2 =
166
- * Bug fix
167
-
168
- = 1.3.1 =
169
- * Enhancement: widget area
170
-
171
- = 1.3.0 =
172
- * Bug fix
173
-
174
- = 1.2.9 =
175
- * Bug Fix: minor changes
176
-
177
- = 1.2.8 =
178
- * Enhancement: new settings
179
- * Bug Fix
180
-
181
- = 1.2.7 =
182
- * Bug Fix: minor bug fixes
183
-
184
- = 1.2.6 =
185
- * Enhancement: new feature - on archive
186
-
187
- = 1.2.5 =
188
- * Bug fix: minor bugs with short tag option
189
-
190
- = 1.2.4 =
191
- * Enhancement: new feature - on static page
192
- * Enhancement: security
193
- * Bug fix
194
-
195
- = 1.2.3 =
196
- * Bug fix: show on main
197
-
198
- = 1.2.2 =
199
- * Enhancement: cut spaces in cryptkey field
200
- * Enhancement: feedback link
201
- * Enhancement: access to plugins by top menu item
202
-
203
- = 1.2.1 =
204
- * Bug Fix: minor bug fixes
205
-
206
- = 1.2.0 =
207
- * Enhancement: user registration.
208
-
209
- = 1.0.0 =
 
 
 
 
 
 
 
 
 
210
  * Initial release
1
+ === Uptolike Social Share Buttons ===
2
+ Tags: +1, UpToLike, AddThis, social buttons, bookmark, bookmarking, like, share, share button, sharing, social bookmarking, social bookmarks, social buttons, кнопки соцсетей, социальные кнопки
3
+ Requires at least: 3.0.1
4
+ Tested up to: 4.4.2
5
+ Stable tag: 1.4.7
6
+
7
+ Uptolike Social Share Buttons - social bookmarking widget with sharing statistics.
8
+
9
+ == Description ==
10
+
11
+ **What Can You Do With UpToLike Social Share Buttons?**
12
+
13
+ * Create custom buttons that will visually appeal to users
14
+ * Easily manage social activity online
15
+ * Increase online engagement through Shares and Likes
16
+ * Attract new visitors from social networks
17
+ * Collect and analyze the social activity of users
18
+ * Adjust content strategy based on analytics
19
+
20
+ UpToLike is a single interface from which you can manage the appearance and efficiency of social buttons on your site, as well as collect and analyze statistics on
21
+ likes, shares, returns, new users, sources of social traffic, and more.
22
+
23
+ **Which social networks does UpToLike Social Share Buttons support?**
24
+
25
+ UpToLike is compatible with 25 popular social networking sites. It supports the following functions: Bookmark, Print, Email, Follow, etc.
26
+
27
+ **Unique Functions of UpToLike Social Share Buttons**
28
+
29
+ * Customization of social buttons:
30
+ 1. 3 different shapes
31
+ 2. 3 sizes
32
+ 3. Hover effect (increase, clockwise rotation)
33
+ 4. 14 button styles
34
+ 5. Button background
35
+ 6. Text color
36
+ 7. Text size of the counter
37
+
38
+ * Social Media Following
39
+ * Automatic text selection: the system gives you the option to share a highlighted piece of text on a social network
40
+ * Gathering unique statistics of social media activity
41
+
42
+ **What statistics does UpToLike collect?**
43
+
44
+ * Number of Likes and Shares on site during the selected period
45
+ * Number of users attracted because of Likes and Shares
46
+ * Separation of traffic on social networks
47
+ * Per-page site activity: how many Likes and Shares for each individual page, and how many new visitors came to each page
48
+ * Social buttons adapted to mobile devices
49
+
50
+ **Uptolike Social Share Buttons - бесплатный русскоязычный плагин социальных кнопок**
51
+
52
+ **Какие задачи выполняет плагин Uptolike?**
53
+
54
+ * Установить на сайте красивые, полностью кастомизрованные социальные кнопки, которые будут нравиться пользователям
55
+ * Управлять социальной активностью пользователей на сайте
56
+ * Увеличивать показатель шаринга на сайте
57
+ * Привлекать новых посетителей из социальных сетей
58
+ * Собирать и анализировать статистику социальной активности пользователей
59
+ * Корректировать контент-стратегию
60
+
61
+ Uptolike – единый интерфейс, откуда можно управлять эффективностью социальных кнопок на сайте, а также собирать и анализировать статистику по лайкам, шарам, количеству возвратов, количеству привлеченных новых пользователей, источниках социального трафика и так далее.
62
+
63
+ **Какие социальные сети поддерживает Uptolike?**
64
+
65
+ Uptolike поддерживает 25 популярных социальных сетей: Вконтакте, Facebook, Одноклассники, Twitter, и т.д.
66
+
67
+ **Уникальные фишки Uptolike**
68
+
69
+ * Полная кастомизация социальных кнопок:
70
+ 1. 3 формы
71
+ 2. 3 размера
72
+ 3. эффект при наведении (увеличение, поворот по часовой стрелке)
73
+ 4. 14 стилей кнопок
74
+ 5. настройка фона кнопок
75
+ 6. выбор цвета текста
76
+ 7. установка размера текста счётчика
77
+
78
+ * Функция фолловинга
79
+ * Функция цитирования по тексту – выделенный участок текста автоматически предлагается расшарить в социальной сети
80
+ * Уникальная статистика социальной активности на сайте
81
+ * Кнопки социальных сетей, адаптированные под мобильные устройства
82
+
83
+ **Статистика, которую собирает Uptolike**
84
+
85
+ * Количество лайков и шаров на сайте за выбранный период
86
+ * Количество привлеченных пользователей, благодаря лайкам и шарам
87
+ * Разделение трафика по социальным сетям
88
+ * Постраничная статистика по сайту: сколько лайков и шаров получила каждая отдельная. страница сайта, и сколько новых посетителей пришли именно на эту страницу
89
+
90
+ == Installation ==
91
+ 1. Go to Plugins -> Add New
92
+ 2. Search for Uptolike
93
+ 3. Install the plugin called *Uptolike Social Share Buttons* and activate it
94
+ 4. Adjust your settings
95
+ 5. Request and fill the secret key field, if you want to receive the statistics
96
+ 6. Enjoy!
97
+
98
+ ***
99
+
100
+ 1. Выберите Плагины -> Добавить новый
101
+ 2. В строке поиска введите Uptolike
102
+ 3. Установите плагин *Uptolike Social Share Buttons* и активируйте
103
+ 4. Настройте внешний вид кнопок
104
+ 5. Для отображения статистики получите на адресс электронной почты секретный ключ и введите его на странице Статистика
105
+ 6. Наслаждайтесь!
106
+
107
+ == Frequently Asked Questions ==
108
+ Answers to Frequently Asked Questions you can find at http://uptolike.ru/faq
109
+
110
+ ***
111
+
112
+ Ответы на часто задаваемые вопросы вы можете найти на http://uptolike.ru/faq
113
+
114
+ == Screenshots ==
115
+ 1. Customizing sharing buttons
116
+ 2. Buttons appearance
117
+ 3. Traffic and sharing statistics
118
+
119
+ == Changelog ==
120
+ = 1.4.7 =
121
+ * Исправлена логика вывода виджета на всех страницах
122
+ * Исправлен баг с ориентацией панели
123
+ * Исправлен баг с дублированием параметра data-url
124
+ * Исправлен баг с параметрами плагина по умолчанию
125
+ * Рефакторинг кода
126
+ * Реструктуризация плагина
127
+
128
+ == Changelog ==
129
+ = 1.4.6 =
130
+ * Исправлено корректное отображение виджета на главной странице
131
+
132
+ = 1.4.5 =
133
+ * Code refactor
134
+ * Minor fix
135
+
136
+ = 1.4.4 =
137
+ * Bug fix
138
+
139
+ = 1.4.3 =
140
+ * Bug fix
141
+
142
+ = 1.4.2 =
143
+ * Bug fix
144
+ * Enhancement: rename
145
+
146
+ = 1.4.1 =
147
+ * Enhancement: settings
148
+
149
+ = 1.4.0 =
150
+ * Bug fix
151
+
152
+ = 1.3.9 =
153
+ * Enhancement: settings
154
+
155
+ = 1.3.8 =
156
+ * Enhancement: new control panel
157
+ * Bug fix
158
+
159
+ = 1.3.7 =
160
+ * Enhancement: security
161
+
162
+ = 1.3.6 =
163
+ * Bug fix
164
+
165
+ = 1.3.5 =
166
+ * Enhancement: new align and shortcode settings
167
+
168
+ = 1.3.4 =
169
+ * Bug fix
170
+
171
+ = 1.3.3 =
172
+ * Enhancement
173
+
174
+ = 1.3.2 =
175
+ * Bug fix
176
+
177
+ = 1.3.1 =
178
+ * Enhancement: widget area
179
+
180
+ = 1.3.0 =
181
+ * Bug fix
182
+
183
+ = 1.2.9 =
184
+ * Bug Fix: minor changes
185
+
186
+ = 1.2.8 =
187
+ * Enhancement: new settings
188
+ * Bug Fix
189
+
190
+ = 1.2.7 =
191
+ * Bug Fix: minor bug fixes
192
+
193
+ = 1.2.6 =
194
+ * Enhancement: new feature - on archive
195
+
196
+ = 1.2.5 =
197
+ * Bug fix: minor bugs with short tag option
198
+
199
+ = 1.2.4 =
200
+ * Enhancement: new feature - on static page
201
+ * Enhancement: security
202
+ * Bug fix
203
+
204
+ = 1.2.3 =
205
+ * Bug fix: show on main
206
+
207
+ = 1.2.2 =
208
+ * Enhancement: cut spaces in cryptkey field
209
+ * Enhancement: feedback link
210
+ * Enhancement: access to plugins by top menu item
211
+
212
+ = 1.2.1 =
213
+ * Bug Fix: minor bug fixes
214
+
215
+ = 1.2.0 =
216
+ * Enhancement: user registration.
217
+
218
+ = 1.0.0 =
219
  * Initial release
reg_sample.html DELETED
@@ -1,9 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title></title>
5
- </head>
6
- <body>
7
-
8
- </body>
9
- </html>
 
 
 
 
 
 
 
 
 
test.html DELETED
@@ -1,15 +0,0 @@
1
- <script type="text/javascript">(function (w, doc) {
2
- if (!w.__utlWdgt) {
3
- w.__utlWdgt = true;
4
- var d = doc, s = d.createElement('script'), g = 'getElementsByTagName';
5
- s.type = 'text/javascript';
6
- s.charset = 'UTF-8';
7
- s.async = true;
8
- s.src = ('https:' == w.location.protocol ? 'https' : 'http') + '://w.uptolike.com/widgets/v1/uptolike.js';
9
- var h = d[g]('body')[0];
10
- h.appendChild(s);
11
- }
12
- })(window, document);
13
- </script>
14
- <div data-url data-background-alpha="0.0" data-orientation="horizontal" data-text-color="000000" data-share-shape="round-rectangle" data-buttons-color="ff9300" data-sn-ids="fb.tw.ok.vk.gp.mr." data-counter-background-color="ffffff" data-share-counter-size="11" data-share-size="30" data-background-color="ededed" data-share-counter-type="common" data-pid data-counter-background-alpha="1.0" data-share-style="1" data-mode="share" data-following-enable="false" data-like-text-enable="false" data-selection-enable="true" data-icon-color="ffffff" class="uptolike-buttons">
15
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
uninstall.php CHANGED
@@ -1,13 +1,15 @@
1
  <?php
2
 
3
- if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) )
4
  exit();
5
 
6
  function uptolike_delete_plugin() {
7
 
8
- delete_option('my_option_name');
 
9
  }
10
 
11
  uptolike_delete_plugin();
12
 
13
- ?>
 
1
  <?php
2
 
3
+ if (!defined('WP_UNINSTALL_PLUGIN'))
4
  exit();
5
 
6
  function uptolike_delete_plugin() {
7
 
8
+ delete_option('uptolike_options');
9
+ delete_option('widget_uptolikewidget');
10
  }
11
 
12
  uptolike_delete_plugin();
13
 
14
+ ?>
15
+
uptolike_share_widget.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: UpToLike Social Share Buttons
4
  Plugin URI: https://uptolike.com/
5
  Description: Uptolike Social Share Buttons - social bookmarking widget with sharing statistics.
6
- Version: 1.4.6
7
  Author: Uptolike Team
8
  Author URI: https://uptolike.com/
9
  */
@@ -11,3 +11,4 @@ Author URI: https://uptolike.com/
11
  // Creating the widget
12
 
13
  include 'widget_options.php';
 
3
  Plugin Name: UpToLike Social Share Buttons
4
  Plugin URI: https://uptolike.com/
5
  Description: Uptolike Social Share Buttons - social bookmarking widget with sharing statistics.
6
+ Version: 1.4.7
7
  Author: Uptolike Team
8
  Author URI: https://uptolike.com/
9
  */
11
  // Creating the widget
12
 
13
  include 'widget_options.php';
14
+
usb-admin.php CHANGED
@@ -1,154 +1,187 @@
1
- <?php
2
-
3
- /* 1.4.6 26/02/16 */
4
-
5
- function constructorIframe($projectId, $partnerId, $mail, $cryptKey)
6
- {
7
- $params = array('mail' => $mail,
8
- 'partner' => $partnerId,
9
- 'projectId' => $projectId);
10
-
11
- $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId . '&projectId=' . $projectId . $cryptKey;
12
- $signature = md5($paramsStr);
13
- $params['signature'] = $signature;
14
- if ('' !== $cryptKey) {
15
- $finalUrl = 'https://uptolike.com/api/constructor.html?' . http_build_query($params);
16
- } else $finalUrl = 'https://uptolike.com/api/constructor.html';
17
-
18
- return $finalUrl;
19
- }
20
-
21
- function statIframe($projectId, $partnerId, $mail, $cryptKey)
22
- {
23
- $params = array(
24
- 'mail' => $mail,
25
- 'partner' => $partnerId,
26
- 'projectId' => $projectId,
27
-
28
- );
29
- $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId . '&projectId=' . $projectId;
30
- $signature = md5($paramsStr . $cryptKey);
31
- $params['signature'] = $signature;
32
- $finalUrl = 'https://uptolike.com/api/statistics.html?' . http_build_query($params);
33
-
34
- return $finalUrl;
35
- }
36
-
37
- function usb_admin_page()
38
- {
39
- $options = get_option('my_option_name');
40
-
41
- if ((isset($options['uptolike_email'])) && ('' !== $options['uptolike_email'])) {
42
- $email = $options['uptolike_email'];
43
- } else $email = get_option('admin_email');
44
- $partnerId = 'cms';
45
- $projectId = 'cms' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
46
- $projectId = str_replace('.', '', $projectId);
47
- $projectId = str_replace('-', '', $projectId);
48
- $options = get_option('my_option_name');
49
- if (is_array($options) && array_key_exists('id_number', $options)) {
50
- $cryptKey = $options['id_number'];
51
- } else $cryptKey = '';
52
-
53
- ?>
54
- <script type="text/javascript">
55
- <?php include('main.js'); ?>
56
- </script>
57
- <style type="text/css">
58
- <?php include('uptolike_style.css')?>
59
- </style>
60
- <div id="uptolike_site_url" style="display: none"><?php echo get_site_url();?></div>
61
- <div class="wrap">
62
- <h2 class="placeholder">&nbsp;</h2>
63
- <div id="wrapper">
64
- <form id="settings_form" method="post" action="options.php">
65
- <h1>UpToLike виджет</h1>
66
- <h2 class="nav-tab-wrapper">
67
- <a class="nav-tab nav-tab-active" href="#" id="construct">
68
- Конструктор
69
- </a>
70
- <a class="nav-tab" href="#" id="stat">
71
- Статистика
72
- </a>
73
- <a class="nav-tab" href="#" id="settings">
74
- Настройки
75
- </a>
76
- </h2>
77
- <div class="wrapper-tab active" id="con_construct">
78
- <iframe id='cons_iframe' style='height: 445px;width: 100%;'
79
- data-src="<?php echo constructorIframe($projectId, $partnerId, $email, $cryptKey); ?>"></iframe>
80
- <br>
81
- <a onclick="getCode();" href="#">
82
- <button type="reset">Сохранить изменения</button>
83
- </a>
84
- </div>
85
- <div class="wrapper-tab" id="con_stat">
86
-
87
- <iframe style="width: 100%;height: 380px;" id="stats_iframe" data-src="<?php echo statIframe($projectId, $partnerId, $email, $cryptKey); ?>">
88
- </iframe>
89
-
90
- <div id="before_key_req">Введите ваш адрес электронной почты для получения ключа.</div>
91
- <div id="after_key_req">На ваш адрес электронной почты отправлен секретный ключ. Введите его в поле ниже<br/>
92
- Если письмо с ключом долго не приходит, возможно оно попало в Спам.<br/><br/>
93
- Если ключ так и не был получен напишите письмо в службу поддержки: <a href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a><br/>
94
- В письме пришлите, пожалуйста, адрес вашего сайта и адрес электронной почты, указанный в плагине.<br/>
95
- </div>
96
- <table>
97
- <tr id="email_tr"> <td>Email: </td> <td> <input type="text" id="uptolike_email_field"> </td> </tr>
98
- <tr id="cryptkey_field"> <td>Ключ: </td> <td> <input type="text" id="uptolike_cryptkey"> </td> </tr>
99
- <tr id="get_key_btn_field"> <td> </td> <td> <button id="get_key" type="button"> Получить ключ </button> </td> </tr>
100
- <tr id="bad_key_field"><td colspan="2" >Введен неверный ключ! Убедитесь что вы скопировали ключ без лишних символов (пробелов и т.д.)</td></tr>
101
- <tr id="foreignAccess_field"><td colspan="2" >Данный проект принадлежит другому пользователю. Обратитесь в службу поддержки</td></tr>
102
- <tr id="key_auth_field"> <td> </td> <td> <button id="auth" type="button"> Авторизация </button> </td> </tr>
103
- </table>
104
- <div>Обратная связь: <a href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a></div>
105
- </div>
106
- <div class="wrapper-tab " id="con_settings">
107
- <div class="utl_left_block">
108
- <?php
109
- $my_settings_page = new MySettingsPage();
110
- $my_settings_page->page_init();
111
- settings_fields('my_option_group');
112
- do_settings_sections($my_settings_page->settings_page_name);
113
- ?>
114
- <input type="submit" name="submit_btn" value="Cохранить изменения">
115
- <br>
116
- </div>
117
- <div class="utl_right_block">
118
- <div class="utl_blok1" >
119
- <div class="utl_blok2" >
120
- <div class="utl_logo utl_i_logo">
121
- </div>
122
- </div>
123
- <div class="utl_innertext" >Для вставки шорткода в .php файл шаблона нужно использовать конструкцию
124
- <br><b><i>
125
- &lt;?php echo do_shortcode("[uptolike]"); ?&gt;<br></i></b>
126
- Для вставки в режиме визуального редактора достаточно вставить<b> <i>[uptolike]</i></b>.</div>
127
- </div>
128
- <div class="utl_blok1" >
129
- <div class="utl_blok2" >
130
- <div class="utl_logo utl_like_logo">
131
- </div>
132
- </div>
133
- <div class="utl_innertext" >Данный плагин полностью бесплатен. Мы регулярно его улучшаем и добавляем новые функции.<br>
134
- Пожалуйста, оставьте свой отзыв на <a href="https://wordpress.org/support/view/plugin-reviews/uptolike-share">данной странице</a>. Спасибо! <br>
135
- </div>
136
- </div>
137
- <div class="utl_blok1" >
138
- <div class="utl_blok2" >
139
- <div class="utl_logo utl_mail_logo">
140
- </div>
141
- </div>
142
- <div class="utl_innertext" ><a href="http://uptolike.ru">Uptolike.ru</a> - конструктор социальных кнопок для вашего сайта с расширенным функционалом.<br>
143
- Служба поддержки: <a href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a></div>
144
- </div>
145
- </div>
146
- </div>
147
- </form>
148
- </div>
149
- </div>
150
- <?php
151
- }
152
- //$my_settings_page->create_admin_page();
153
-
154
- usb_admin_page();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function constructorIframe($projectId, $partnerId, $mail, $cryptKey) {
4
+ $params = array('mail' => $mail, 'partner' => $partnerId, 'projectId' => $projectId);
5
+
6
+ $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId . '&projectId=' . $projectId . $cryptKey;
7
+ $signature = md5($paramsStr);
8
+ $params['signature'] = $signature;
9
+ if ('' !== $cryptKey) {
10
+ $finalUrl = 'https://uptolike.com/api/constructor.html?' . http_build_query($params);
11
+ } else $finalUrl = 'https://uptolike.com/api/constructor.html';
12
+
13
+ return $finalUrl;
14
+ }
15
+
16
+ function statIframe($projectId, $partnerId, $mail, $cryptKey) {
17
+ $params = array('mail' => $mail, 'partner' => $partnerId, 'projectId' => $projectId,
18
+
19
+ );
20
+ $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId . '&projectId=' . $projectId;
21
+ $signature = md5($paramsStr . $cryptKey);
22
+ $params['signature'] = $signature;
23
+ $finalUrl = 'https://uptolike.com/api/statistics.html?' . http_build_query($params);
24
+
25
+ return $finalUrl;
26
+ }
27
+
28
+ function usb_admin_page() {
29
+ $options = get_option('uptolike_options');
30
+
31
+ if ((isset($options['uptolike_email'])) && ('' !== $options['uptolike_email'])) {
32
+ $email = $options['uptolike_email'];
33
+ } else $email = get_option('admin_email');
34
+ $partnerId = 'cms';
35
+ $projectId = 'cms' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
36
+ $projectId = str_replace('.', '', $projectId);
37
+ $projectId = str_replace('-', '', $projectId);
38
+ $options = get_option('uptolike_options');
39
+ if (is_array($options) && array_key_exists('id_number', $options)) {
40
+ $cryptKey = $options['id_number'];
41
+ } else $cryptKey = '';
42
+
43
+ ?>
44
+ <script type="text/javascript">
45
+ <?php include('js/main.js'); ?>
46
+ </script>
47
+ <style type="text/css">
48
+ <?php include('css/uptolike_style.css')?>
49
+ </style>
50
+ <div id="uptolike_site_url" style="display: none"><?php echo get_site_url(); ?></div>
51
+ <div class="wrap">
52
+ <h2 class="placeholder">&nbsp;</h2>
53
+
54
+ <div id="wrapper">
55
+ <form id="settings_form" method="post" action="options.php">
56
+ <h1>UpToLike виджет</h1>
57
+
58
+ <h2 class="nav-tab-wrapper">
59
+ <a class="nav-tab nav-tab-active" href="#" id="construct">
60
+ Конструктор
61
+ </a>
62
+ <a class="nav-tab" href="#" id="stat">
63
+ Статистика
64
+ </a>
65
+ <a class="nav-tab" href="#" id="settings">
66
+ Настройки
67
+ </a>
68
+ </h2>
69
+
70
+ <div class="wrapper-tab active" id="con_construct">
71
+ <iframe id='cons_iframe' style='height: 445px;width: 100%;'
72
+ data-src="<?php echo constructorIframe($projectId, $partnerId, $email, $cryptKey); ?>"></iframe>
73
+ <br>
74
+ <a onclick="getCode();" href="#">
75
+ <button type="reset">Сохранить изменения</button>
76
+ </a>
77
+ </div>
78
+ <div class="wrapper-tab" id="con_stat">
79
+
80
+ <iframe style="width: 100%;height: 380px;" id="stats_iframe"
81
+ data-src="<?php echo statIframe($projectId, $partnerId, $email, $cryptKey); ?>">
82
+ </iframe>
83
+
84
+ <div id="before_key_req">Введите ваш адрес электронной почты для получения
85
+ ключа.
86
+ </div>
87
+ <div id="after_key_req">На ваш адрес электронной почты отправлен секретный ключ.
88
+ Введите его в поле ниже<br/>
89
+ Если письмо с ключом долго не приходит, возможно оно попало в
90
+ Спам.<br/><br/>
91
+ Если ключ так и не был получен напишите письмо в службу поддержки: <a
92
+ href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a><br/>
93
+ В письме пришлите, пожалуйста, адрес вашего сайта и адрес электронной почты,
94
+ указанный в плагине.<br/>
95
+ </div>
96
+ <table>
97
+ <tr id="email_tr">
98
+ <td>Email:</td>
99
+ <td><input type="text" id="uptolike_email_field"></td>
100
+ </tr>
101
+ <tr id="cryptkey_field">
102
+ <td>Ключ:</td>
103
+ <td><input type="text" id="uptolike_cryptkey"></td>
104
+ </tr>
105
+ <tr id="get_key_btn_field">
106
+ <td></td>
107
+ <td>
108
+ <button id="get_key" type="button"> Получить ключ</button>
109
+ </td>
110
+ </tr>
111
+ <tr id="bad_key_field">
112
+ <td colspan="2">Введен неверный ключ! Убедитесь что вы скопировали ключ
113
+ без лишних символов (пробелов и т.д.)
114
+ </td>
115
+ </tr>
116
+ <tr id="foreignAccess_field">
117
+ <td colspan="2">Данный проект принадлежит другому пользователю.
118
+ Обратитесь в службу поддержки
119
+ </td>
120
+ </tr>
121
+ <tr id="key_auth_field">
122
+ <td></td>
123
+ <td>
124
+ <button id="auth" type="button"> Авторизация</button>
125
+ </td>
126
+ </tr>
127
+ </table>
128
+ <div>Обратная связь: <a href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a>
129
+ </div>
130
+ </div>
131
+ <div class="wrapper-tab " id="con_settings">
132
+ <div class="utl_left_block">
133
+ <?php
134
+ $my_settings_page = new MySettingsPage();
135
+ $my_settings_page->page_init();
136
+ settings_fields('my_option_group');
137
+ do_settings_sections($my_settings_page->settings_page_name);
138
+ ?>
139
+ <input type="submit" name="submit_btn" value="Cохранить изменения">
140
+ <br>
141
+ </div>
142
+ <div class="utl_right_block">
143
+ <div class="utl_blok1">
144
+ <div class="utl_blok2">
145
+ <div class="utl_logo utl_i_logo">
146
+ </div>
147
+ </div>
148
+ <div class="utl_innertext">Для вставки шорткода в .php файл шаблона
149
+ нужно использовать конструкцию
150
+ <br><b><i>
151
+ &lt;?php echo do_shortcode("[uptolike]"); ?&gt;<br></i></b>
152
+ Для вставки в режиме визуального редактора достаточно вставить<b>
153
+ <i>[uptolike]</i></b>.
154
+ </div>
155
+ </div>
156
+ <div class="utl_blok1">
157
+ <div class="utl_blok2">
158
+ <div class="utl_logo utl_like_logo">
159
+ </div>
160
+ </div>
161
+ <div class="utl_innertext">Данный плагин полностью бесплатен. Мы
162
+ регулярно его улучшаем и добавляем новые функции.<br>
163
+ Пожалуйста, оставьте свой отзыв на <a
164
+ href="https://wordpress.org/support/view/plugin-reviews/uptolike-share">данной
165
+ странице</a>. Спасибо! <br>
166
+ </div>
167
+ </div>
168
+ <div class="utl_blok1">
169
+ <div class="utl_blok2">
170
+ <div class="utl_logo utl_mail_logo">
171
+ </div>
172
+ </div>
173
+ <div class="utl_innertext"><a href="http://uptolike.ru">Uptolike.ru</a>
174
+ - конструктор социальных кнопок для вашего сайта с расширенным
175
+ функционалом.<br>
176
+ Служба поддержки: <a href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a>
177
+ </div>
178
+ </div>
179
+ </div>
180
+ </div>
181
+ </form>
182
+ </div>
183
+ </div>
184
+ <?php
185
+ }
186
+
187
+ usb_admin_page();
widget_options.php CHANGED
@@ -1,907 +1,798 @@
1
- <?php
2
- //widget_options.php
3
- //1.4.6 26/02/16
4
- class MySettingsPage
5
- {
6
-
7
- public $options;
8
- public $settings_page_name = 'uptolike_settings';
9
- public function __construct()
10
- {
11
- add_action('admin_menu', array($this, 'add_plugin_page'));
12
- add_action('admin_init', array($this, 'page_init'));
13
- $this->options = get_option('my_option_name');
14
- }
15
-
16
-
17
- public function add_plugin_page()
18
- {
19
- add_options_page(
20
- 'Settings Admin',
21
- 'UpToLike',
22
- 'manage_options',
23
- $this->settings_page_name, //'my-setting-admin',
24
- array($this, 'create_admin_page')
25
- );
26
- }
27
-
28
- /** creates url of iframe with statistics page from given params
29
- *
30
- * @param $projectId
31
- * @param $partnerId
32
- * @param $mail
33
- * @param $cryptKey
34
- * @return stringшfr
35
- */
36
- public function statIframe($projectId, $partnerId, $mail, $cryptKey)
37
- {
38
- $params = array(
39
- 'mail' => $mail,
40
- 'partner' => $partnerId,
41
- 'projectId' => $projectId,
42
-
43
- );
44
- $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId. '&projectId=' . $projectId;
45
- $signature = md5($paramsStr . $cryptKey);
46
- $params['signature'] = $signature;
47
- $finalUrl = 'https://uptolike.com/api/statistics.html?' . http_build_query($params);
48
-
49
- return $finalUrl;
50
- }
51
-
52
- /** create url of iframe with constructor from given params
53
- * @param $projectId
54
- * @param $partnerId
55
- * @param $mail
56
- * @param $cryptKey
57
- * @return string
58
- */
59
- public function constructorIframe($projectId, $partnerId, $mail, $cryptKey)
60
- {
61
- $params = array('mail' => $mail,
62
- 'partner' => $partnerId,
63
- 'projectId' => $projectId);
64
-
65
- $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId . '&projectId=' . $projectId . $cryptKey;
66
- $signature = md5($paramsStr);
67
- $params['signature'] = $signature;
68
- if ('' !== $cryptKey) {
69
- $finalUrl = 'https://uptolike.com/api/constructor.html?' . http_build_query($params);
70
- } else $finalUrl = 'https://uptolike.com/api/constructor.html';
71
- return $finalUrl;
72
- }
73
-
74
- /** returns tabs html code. May be replace by proper html code
75
- * @param string $current
76
- */
77
- public function ilc_admin_tabs($current = 'construct')
78
- {
79
- $tabs = array('construct' => 'Конструктор',
80
- 'stat' => 'Статистика',
81
- 'settings' => 'Настройки');
82
-
83
- echo '<div id="icon-themes" class="icon32"><br></div>';
84
- echo '<h2 class="nav-tab-wrapper">';
85
- foreach ($tabs as $tab => $name) {
86
- $class = ($tab == $current) ? ' nav-tab-active' : '';
87
- echo "<a class='nav-tab$class' href='#' id=" . $tab . " ref='?page=" . $this->settings_page_name . "&tab=$tab'>$name</a>";
88
- }
89
- echo '</h2>';
90
- }
91
-
92
- /** render html page with code configuration settings
93
- *
94
- */
95
- public function create_admin_page()
96
- {
97
- $this->options = get_option('my_option_name');
98
- if ((isset($this->options['uptolike_email'])) && ('' !== $this->options['uptolike_email'])) {
99
- $email = $this->options['uptolike_email'];
100
- } else $email = get_option('admin_email');
101
- $partnerId = 'cms';
102
- $projectId = 'cms' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
103
- $projectId = str_replace('.','',$projectId);
104
- $projectId = str_replace('-','',$projectId);
105
- $options = get_option('my_option_name');
106
- if (is_array($options) && array_key_exists('id_number', $options)) {
107
- $cryptKey = $options['id_number'];
108
- } else $cryptKey = '';
109
- ?>
110
- <script type="text/javascript">
111
- <?php include('main.js'); ?>
112
- </script>
113
- <style type="text/css">
114
- <?php include('uptolike_style.css')?>
115
- </style>
116
- <div id="uptolike_site_url" style="display: none"><?php echo get_site_url();?></div>
117
- <div class="wrap">
118
- <h2 class="placeholder">&nbsp;</h2>
119
- <div id="wrapper">
120
- <form id="settings_form" method="post" action="options.php">
121
- <h1> UpToLike виджет</h1>
122
- <h2 class="nav-tab-wrapper">
123
- <a class="nav-tab nav-tab-active" href="#" id="construct">
124
- Конструктор
125
- </a>
126
- <a class="nav-tab" href="#" id="stat">
127
- Статистика
128
- </a>
129
- <a class="nav-tab" href="#" id="settings">
130
- Настройки
131
- </a>
132
- </h2>
133
- <div class="wrapper-tab active" id="con_construct">
134
- <iframe id='cons_iframe' style='height: 445px;width: 100%;' data-src="<?php echo $this->constructorIframe($projectId, $partnerId, $email, $cryptKey); ?>"></iframe>
135
- <br>
136
- <a onclick="getCode();" href="#">
137
- <button type="reset">Сохранить изменения</button>
138
- </a>
139
- </div>
140
- <div class="wrapper-tab" id="con_stat">
141
- <iframe style="width: 100%;height: 380px;" id="stats_iframe" data-src="<?php echo $this->statIframe($projectId, $partnerId, $email, $cryptKey); ?>">
142
- </iframe>
143
- <div id="before_key_req">Введите ваш адрес электронной почты для получения ключа.</div>
144
- <div id="after_key_req">На ваш адрес электронной почты отправлен секретный ключ. Введите его в поле ниже<br/>
145
- Если письмо с ключом долго не приходит, возможно оно попало в Спам.<br/><br/>
146
- Если ключ так и не был получен напишите письмо в службу поддержки: <a href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a><br/>
147
- В письме пришлите, пожалуйста, адрес вашего сайта и адрес электронной почты, указанный в плагине.<br/>
148
- </div>
149
- <table>
150
- <tr id="email_tr"> <td>Email: </td> <td> <input type="text" id="uptolike_email_field"> </td> </tr>
151
- <tr id="cryptkey_field"> <td>Ключ: </td> <td> <input type="text" id="uptolike_cryptkey"> </td> </tr>
152
- <tr id="get_key_btn_field"> <td> </td> <td> <button id="get_key" type="button"> Получить ключ </button> </td> </tr>
153
- <tr id="bad_key_field"><td colspan="2" >Введен неверный ключ! Убедитесь что вы скопировали ключ без лишних символов (пробелов и т.д.)</td></tr>
154
- <tr id="foreignAccess_field"><td colspan="2" >Данный проект принадлежит другому пользователю. Обратитесь в службу поддержки</td></tr>
155
- <tr id="key_auth_field"> <td> </td> <td> <button id="auth" type="button"> Авторизация </button> </td> </tr>
156
- </table>
157
- <div>Обратная связь: <a href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a></div>
158
- </div>
159
- <div class="wrapper-tab" id="con_settings">
160
- <div class="utl_left_block">
161
- <?php
162
- settings_fields('my_option_group');
163
- do_settings_sections('uptolike_settings');
164
- ?>
165
- <input type="submit" name="submit_btn" value="Cохранить изменения">
166
- <br>
167
- </div>
168
- <div class="utl_right_block">
169
- <div class="utl_blok1" >
170
- <div class="utl_blok2" >
171
- <div class="utl_logo utl_i_logo">
172
- </div>
173
- </div>
174
- <div class="utl_innertext" >Для вставки шорткода в .php файл шаблона нужно использовать конструкцию
175
- <br><b><i>
176
- &lt;?php echo do_shortcode("[uptolike]"); ?&gt;<br></i></b>
177
- Для вставки в режиме визуального редактора достаточно вставить<b> <i>[uptolike]</i></b>.</div>
178
- </div>
179
- <div class="utl_blok1" >
180
- <div class="utl_blok2" >
181
- <div class="utl_logo utl_like_logo">
182
- </div>
183
- </div>
184
- <div class="utl_innertext" >Данный плагин полностью бесплатен. Мы регулярно его улучшаем и добавляем новые функции.<br>
185
- Пожалуйста, оставьте свой отзыв на <a href="https://wordpress.org/support/view/plugin-reviews/uptolike-share">данной странице</a>. Спасибо! <br>
186
- </div>
187
- </div>
188
- <div class="utl_blok1" >
189
- <div class="utl_blok2" >
190
- <div class="utl_logo utl_mail_logo">
191
- </div>
192
- </div>
193
- <div class="utl_innertext" ><a href="http://uptolike.ru">Uptolike.ru</a> - конструктор социальных кнопок для вашего сайта с расширенным функционалом.<br>
194
- Служба поддержки: <a href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a></div>
195
- </div>
196
- </div>
197
-
198
- </div>
199
- </form>
200
- </div>
201
- </div>
202
- <?php
203
- }
204
-
205
- public function page_init()
206
- {
207
- register_setting(
208
- 'my_option_group', // Option group
209
- 'my_option_name', // Option name
210
- array($this, 'sanitize') // Sanitize
211
- );
212
-
213
- add_settings_section(
214
- 'setting_section_id', // ID
215
- 'Настройки отображения блока Uptolike', // Title
216
- array($this, 'print_section_info'), // Callback
217
- $this->settings_page_name//'my-setting-admin' // Page
218
- );
219
-
220
- add_settings_field(
221
- 'widget_code', // ID
222
- 'код виджета', // Title
223
- array($this, 'widget_code_callback'), // Callback
224
- $this->settings_page_name, //'my-setting-admin', // Page
225
- 'setting_section_id' // Section
226
- );
227
-
228
- add_settings_field(
229
- 'data_pid', // ID
230
- 'Ключ(CryptKey)', // Title
231
- array($this, 'id_number_callback'), // Callback
232
- $this->settings_page_name, //'my-setting-admin', // Page
233
- 'setting_section_id' // Section
234
- );
235
-
236
- add_settings_field(
237
- 'email', //ID
238
- 'email для регистрации',
239
- array($this, 'uptolike_email_callback'),
240
- $this->settings_page_name, //'my-setting-admin',
241
- 'setting_section_id'
242
- );
243
-
244
- /* add_settings_field(
245
- 'on_main_static', //ID
246
- 'Располагать на главной странице в фиксированном блоке',
247
- array($this, 'uptolike_on_main_static_callback'),
248
- $this->settings_page_name, //'my-setting-admin',
249
- 'setting_section_id'
250
- );
251
- */
252
-
253
- add_settings_field(
254
- 'on_main', //ID
255
- 'На главной странице ',
256
- array($this, 'uptolike_on_main_callback'),
257
- $this->settings_page_name, //'my-setting-admin',
258
- 'setting_section_id'
259
- );
260
-
261
- add_settings_field(
262
- 'on_page', //ID
263
- 'На статических страницах',
264
- array($this, 'uptolike_on_page_callback'),
265
- $this->settings_page_name, //'my-setting-admin',
266
- 'setting_section_id'
267
- );
268
-
269
- add_settings_field(
270
- 'on_archive', //ID
271
- 'В анонсах постов',
272
- array($this, 'uptolike_on_archive_callback'),
273
- $this->settings_page_name, //'my-setting-admin',
274
- 'setting_section_id'
275
- );
276
-
277
- add_settings_field(
278
- 'on_special_pages', //ID
279
- 'На спец. страницах <p class="utl_quest"><img class="utl_quest" src="/wp-content/plugins/uptolike-share/quest.png"><span class="utl_quest">Отображение блока кнопок на страницах, созданных плагинами (WooCommerce, WP-Shop и т.д.)</span></p>',
280
- array($this, 'uptolike_on_special_pages_callback'),
281
- $this->settings_page_name, //'my-setting-admin',
282
- 'setting_section_id'
283
- );
284
-
285
- add_settings_field(
286
- 'widget_position', //ID
287
- 'Расположение блока',
288
- array($this, 'uptolike_widget_position_callback'),
289
- $this->settings_page_name, //'my-setting-admin',
290
- 'setting_section_id'
291
- );
292
-
293
- add_settings_field(
294
- 'widget_align', //ID
295
- 'Выравнивание блока',
296
- array($this, 'uptolike_widget_align_callback'),
297
- $this->settings_page_name, //'my-setting-admin',
298
- 'setting_section_id'
299
- );
300
-
301
- add_settings_field(
302
- 'widget_mode', //ID
303
- 'Режим работы',
304
- array($this, 'uptolike_widget_mode_callback'),
305
- $this->settings_page_name, //'my-setting-admin',
306
- 'setting_section_id'
307
- );
308
-
309
- add_settings_field(
310
- 'utl_language', //ID
311
- 'Язык',
312
- array($this, 'uptolike_utl_language_callback'),
313
- $this->settings_page_name, //'my-setting-admin',
314
- 'setting_section_id'
315
- );
316
-
317
- /* add_settings_field(
318
- 'feedback', //ID
319
- 'Обратная связь',
320
- array($this, 'uptolike_feedback_callback'),
321
- $this->settings_page_name, //'my-setting-admin',
322
- 'setting_section_id'
323
- );
324
- */
325
-
326
- add_settings_field(
327
- 'uptolike_json', //ID
328
- 'настройки конструктора',
329
- array($this, 'uptolike_json_callback'),
330
- $this->settings_page_name, //'my-setting-admin',
331
- 'setting_section_id'
332
- );
333
- }
334
-
335
- /**
336
- * Sanitize each setting field as needed
337
- *
338
- * @param array $input Contains all settings fields as array keys
339
- */
340
- public function sanitize($input)
341
- {
342
- $new_input = array();
343
- if (isset($input['id_number']))
344
- $new_input['id_number'] = str_replace(' ','',$input['id_number']);
345
-
346
- if (isset($input['widget_code']))
347
- $new_input['widget_code'] = $input['widget_code'];
348
-
349
- if (isset($input['uptolike_email']))
350
- $new_input['uptolike_email'] = $input['uptolike_email'];
351
-
352
- if (isset($input['before_content']))
353
- $new_input['before_content'] = $input['before_content'];
354
-
355
- if (isset($input['on_main_static'])) {
356
- $new_input['on_main_static'] = 1;
357
- } else $new_input['on_main_static'] = 0;
358
-
359
- if (isset($input['on_main'])) {
360
- $new_input['on_main'] = 1;
361
- } else $new_input['on_main'] = 0;
362
-
363
- if (isset($input['on_page'])) {
364
- $new_input['on_page'] = 1;
365
- } else $new_input['on_page'] = 0;
366
-
367
- if (isset($input['on_special_pages'])) {
368
- $new_input['on_special_pages'] = 1;
369
- } else $new_input['on_special_pages'] = 0;
370
-
371
- if (isset($input['on_archive'])) {
372
- $new_input['on_archive'] = 1;
373
- } else $new_input['on_archive'] = 0;
374
-
375
- if (isset($input['email']))
376
- $new_input['email'] = $input['email'];
377
-
378
- if (isset($input['after_content']))
379
- $new_input['after_content'] = $input['after_content'];
380
-
381
- if (isset($input['widget_position']))
382
- $new_input['widget_position'] = $input['widget_position'];
383
-
384
- if (isset($input['widget_mode']))
385
- $new_input['widget_mode'] = $input['widget_mode'];
386
-
387
- if (isset($input['widget_align']))
388
- $new_input['widget_align'] = $input['widget_align'];
389
-
390
- if (isset($input['utl_language']))
391
- $new_input['utl_language'] = $input['utl_language'];
392
-
393
-
394
- if (isset($input['uptolike_json']))
395
- $new_input['uptolike_json'] = $input['uptolike_json'];
396
-
397
- return $new_input;
398
- }
399
-
400
-
401
- public function print_section_info()
402
- {
403
- //print 'Enter your settings below:';
404
- }
405
-
406
- public function widget_code_callback()
407
- {
408
- printf(
409
- '<textarea id="widget_code" name="my_option_name[widget_code]" >%s</textarea>',
410
- isset($this->options['widget_code']) ? esc_attr($this->options['widget_code']) : ''
411
- );
412
- }
413
-
414
- /** 12536473050877
415
- * Get the settings option array and print one of its values
416
- */
417
- public function id_number_callback()
418
- {
419
- printf(
420
- '<input type="text" class="id_number" name="my_option_name[id_number]" value="%s" />',
421
- isset($this->options['id_number']) ? esc_attr($this->options['id_number']) : ''
422
- );
423
- }
424
-
425
- public function uptolike_email_callback()
426
- {
427
- printf(
428
- '<input type="text" id="uptolike_email" name="my_option_name[uptolike_email]" value="%s" />',
429
- isset($this->options['uptolike_email']) ? esc_attr($this->options['uptolike_email']) : ''
430
- );
431
- }
432
-
433
- public function uptolike_json_callback()
434
- {
435
- printf(
436
- '<input type="hidden" id="uptolike_json" name="my_option_name[uptolike_json]" value="%s" />',
437
- isset($this->options['uptolike_json']) ? esc_attr($this->options['uptolike_json']) : ''
438
- );
439
- }
440
-
441
- public function uptolike_partner_id_callback()
442
- {
443
- printf(
444
- '<input type="text" id="uptolike_partner" name="my_option_name[uptolike_partner]" value="%s" />',
445
- isset($this->options['uptolike_partner']) ? esc_attr($this->options['uptolike_partner']) : ''
446
- );
447
- }
448
-
449
- public function uptolike_feedback_callback()
450
- {
451
- echo '<a href="mailto:uptolikeshare@gmail.com" target="_top"> uptolikeshare@gmail.com</a>';
452
- }
453
-
454
- public function uptolike_project_callback()
455
- {
456
- printf(
457
- '<input type="text" id="uptolike_project" name="my_option_name[uptolike_project]" value="%s" />',
458
- isset($this->options['uptolike_project']) ? esc_attr($this->options['uptolike_project']) : ''
459
- );
460
- }
461
-
462
- public function uptolike_on_main_static_callback()
463
- {
464
- echo '<input type="checkbox" id="on_main_static" name="my_option_name[on_main_static]"';
465
- echo ($this->options['on_main_static'] == '1' ? 'checked="checked"' : ''); echo ' />';
466
-
467
- }
468
-
469
- public function uptolike_on_main_callback()
470
- {
471
- echo '<input type="checkbox" id="on_main" name="my_option_name[on_main]"';
472
- echo ($this->options['on_main'] == '1' ? 'checked="checked"' : ''); echo ' />';
473
-
474
- }
475
- public function uptolike_on_page_callback()
476
- {
477
- echo '<input type="checkbox" id="on_page" name="my_option_name[on_page]"';
478
- echo ($this->options['on_page'] == '1' ? 'checked="checked"' : ''); echo ' />';
479
-
480
- }
481
- public function uptolike_on_special_pages_callback()
482
- {
483
- echo '<input type="checkbox" id="on_special_pages" name="my_option_name[on_special_pages]"';
484
- echo ($this->options['on_special_pages'] == '1' ? 'checked="checked"' : ''); echo ' />';
485
-
486
- }
487
-
488
-
489
- public function uptolike_on_archive_callback()
490
- {
491
- echo '<input type="checkbox" id="on_archive" name="my_option_name[on_archive]"';
492
- echo ($this->options['on_archive'] == '1' ? 'checked="checked"' : ''); echo ' />';
493
-
494
- }
495
-
496
- public function uptolike_widget_mode_callback()
497
- {
498
- $plg_mode = $code_mode = $both_mode = $default = '';
499
-
500
- if (isset($this->options['widget_mode'])) {
501
- if ('plg' == $this->options['widget_mode']) {
502
- $plg_mode = "selected='selected'";
503
- } elseif ('code' == $this->options['widget_mode']) {
504
- $code_mode = "selected='selected'";
505
- } elseif ('both' == $this->options['widget_mode']) {
506
- $both_mode = "selected='selected'";
507
- }
508
- } else {
509
- $my_options = get_option('my_option_name');
510
- $my_options['widget_mode'] = 'plg'; // cryptkey store
511
- update_option('my_option_name', $my_options);
512
- }
513
- //$default = "selected='selected'";
514
- echo "<select id='widget_mode' name='my_option_name[widget_mode]'>
515
- <option {$plg_mode} value='plg'>Плагин</option>
516
- <option {$code_mode} value='code'>Шорткод</option>
517
- <option {$both_mode} value='both'>Плагин и шорткод</option>
518
- </select>";
519
- }
520
-
521
- public function uptolike_widget_align_callback()
522
- {
523
- $left = $right = $center = $default = '';
524
-
525
- if (isset($this->options['widget_align'])) {
526
- if ('left' == $this->options['widget_align']) {
527
- $left = "selected='selected'";
528
- } elseif ('right' == $this->options['widget_align']) {
529
- $right = "selected='selected'";
530
- } elseif ('center' == $this->options['widget_align']) {
531
- $center = "selected='selected'";
532
- }
533
- } else {
534
- $my_options = get_option('my_option_name');
535
- $my_options['widget_align'] = 'left'; // cryptkey store
536
- update_option('my_option_name', $my_options);
537
- }
538
-
539
- echo "<select id='widget_align' name='my_option_name[widget_align]'>
540
- <option {$left} value='left'>По левому краю</option>
541
- <option {$right} value='right'>По правому краю</option>
542
- <option {$center} value='center'>По центру</option>
543
- </select>";
544
- }
545
-
546
- public function uptolike_widget_position_callback()
547
- {
548
- $top = $bottom = $both = $default = '';
549
-
550
- if (isset($this->options['widget_position'])) {
551
- if ('top' == $this->options['widget_position']) {
552
- $top = "selected='selected'";
553
- } elseif ('bottom' == $this->options['widget_position']) {
554
- $bottom = "selected='selected'";
555
- } elseif ('both' == $this->options['widget_position']) {
556
- $both = "selected='selected'";
557
- } else {
558
- $bottom = "selected='selected'";
559
- }
560
- } else {
561
- $my_options = get_option('my_option_name');
562
- $my_options['widget_position'] = 'bottom'; // cryptkey store
563
- update_option('my_option_name', $my_options);
564
- }
565
- $default = "selected='selected'";
566
- echo "<select id='widget_position' name='my_option_name[widget_position]'>
567
- <option {$top} value='top'>Только сверху</option>
568
- <option {$bottom} value='bottom'>Только снизу</option>
569
- <option {$both} value='both'>Сверху и снизу</option>
570
- </select>";
571
- }
572
-
573
- public function uptolike_utl_language_callback() {
574
- // $top = $bottom = $both = $default = '';
575
- $ru = $en = $ua = $de = $es = $it = $pl = $lt = $default = '';
576
- if (isset($this->options['utl_language'])) {
577
- if ('ru' == $this->options['utl_language']) {
578
- $ru = "selected='selected'";
579
- } elseif ('en' == $this->options['utl_language']) {
580
- $en = "selected='selected'";
581
- } elseif ('ua' == $this->options['utl_language']) {
582
- $ua = "selected='selected'";
583
- } elseif ('de' == $this->options['utl_language']) {
584
- $de = "selected='selected'";
585
- } elseif ('es' == $this->options['utl_language']) {
586
- $es = "selected='selected'";
587
- } elseif ('it' == $this->options['utl_language']) {
588
- $it = "selected='selected'";
589
- } elseif ('pl' == $this->options['utl_language']) {
590
- $pl = "selected='selected'";
591
- } elseif ('lt' == $this->options['utl_language']) {
592
- $lt = "selected='selected'";
593
- } else {
594
- $ru = "selected='selected'";
595
- }
596
- } else {
597
- $my_options = get_option('my_option_name');
598
- $my_options['utl_language'] = 'ru'; // cryptkey store
599
- update_option('my_option_name', $my_options);
600
- //$ru = "selected='selected'";
601
- }
602
- //$default = "selected='selected'";
603
- echo "<select id='widget_position' name='my_option_name[utl_language]'>
604
- <option {$ru} value='ru'>Русский</option>
605
- <option {$en} value='en'>Английский</option>
606
- <option {$ua} value='ua'>Украинский</option>
607
- <option {$de} value='de'>Немецкий</option>
608
- <option {$es} value='es'>Испанский</option>
609
- <option {$it} value='it'>Итальянский</option>
610
- <option {$pl} value='pl'>Латвийский</option>
611
- <option {$lt} value='lt'>Польский</option>
612
- </select>";
613
- }
614
- }
615
-
616
- function get_widget_code($url='') {
617
- $options = get_option('my_option_name');
618
- $widget_code = $options['widget_code'];
619
- $protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,strpos( $_SERVER["SERVER_PROTOCOL"],'/'))).'://';
620
- if ($url == ''){
621
- if(is_single()) { $url = get_permalink();} else $url = $protocol.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
622
- }
623
-
624
- $domain = preg_replace('/^www\./', '', get_site_url());
625
- $data_pid = 'cms'.str_replace(array('https://','http://','.','-'),'',$domain);
626
-
627
- $widget_code = str_replace('data-pid="-1"','data-pid="' . $data_pid . '"',$widget_code);
628
- $widget_code = str_replace('data-pid=""','data-pid="' . $data_pid . '"',$widget_code);
629
- $widget_code = str_replace('div data', 'div data-url="' . $url . '" data', $widget_code);
630
- $align = $options['widget_align'];
631
-
632
- $align_style = 'style=" text-align: '.$align.';"';
633
- $widget_code = str_replace('div data-', 'div data-lang="' . $options['utl_language'] . '" data-', $widget_code);
634
- $widget_code = str_replace('<div ', '<div '.$align_style.' ', $widget_code);
635
-
636
- return $widget_code;
637
- }
638
- function add_widget($content)
639
- {
640
- //echo
641
- $options = get_option('my_option_name');
642
- $widget_mode = $options['widget_mode'];
643
- if (is_array($options) && (($widget_mode == 'plg') or ($widget_mode == 'both')) && array_key_exists('widget_code', $options)) {
644
- //$widget_code = get_widget_code();
645
- if (is_page()) {//это страница
646
- if ($options['on_page'] == 1 && ($options['on_main'] == 1 && is_front_page())) {
647
- switch ($options['widget_position']) {
648
- case 'both':
649
- return get_widget_code().$content.get_widget_code();
650
- case 'top':
651
- return get_widget_code().$content;
652
- case 'bottom':
653
- return $content.get_widget_code();
654
- }
655
- } elseif ($options['on_page'] == 1 && ($options['on_main'] != 1 && !(is_front_page()))) {
656
- switch ($options['widget_position']) {
657
- case 'both':
658
- return get_widget_code().$content.get_widget_code();
659
- case 'top':
660
- return get_widget_code().$content;
661
- case 'bottom':
662
- return $content.get_widget_code();
663
- }
664
- } else return $content;
665
- } elseif (is_archive()) {
666
- if ($options['on_archive'] == 1) {
667
- switch ($options['widget_position']) {
668
- case 'both':
669
- return get_widget_code(get_permalink()).$content.get_widget_code(get_permalink());
670
- case 'top':
671
- return get_widget_code(get_permalink()).$content;
672
- case 'bottom':
673
- return $content.get_widget_code(get_permalink());
674
- }
675
- } else return $content;
676
- } elseif (is_front_page()) {
677
- if ($options['on_main'] == 1 && !(is_home())) {
678
- switch ($options['widget_position']) {
679
- case 'both':
680
- return get_widget_code(get_permalink()).$content.get_widget_code(get_permalink());
681
- case 'top':
682
- return get_widget_code(get_permalink()).$content;
683
- case 'bottom':
684
- return $content.get_widget_code(get_permalink());
685
- }
686
- } elseif ($options['on_main'] == 1 && is_home()) {
687
- switch ($options['widget_position']) {
688
- case 'both':
689
- return get_widget_code(get_permalink()).$content.get_widget_code(get_permalink());
690
- case 'top':
691
- return get_widget_code(get_permalink()).$content;
692
- case 'bottom':
693
- return $content.get_widget_code(get_permalink());
694
- }
695
- } else return $content;
696
- } else {
697
- switch ($options['widget_position']) {
698
- case 'both':
699
- return get_widget_code().$content.get_widget_code();
700
- case 'top':
701
- return get_widget_code().$content;
702
- case 'bottom':
703
- return $content.get_widget_code();
704
- }
705
- };
706
-
707
- } else {
708
- return $content;
709
- }
710
- }
711
-
712
- add_filter('the_content', 'add_widget', 100);
713
-
714
- function uptolike_shortcode( $atts ){
715
- $options = get_option('my_option_name');
716
- $widget_mode = $options['widget_mode'];
717
- if(($widget_mode == 'code') or ($widget_mode == 'both')) {
718
- return get_widget_code();
719
- };
720
- }
721
- add_shortcode( 'uptolike', 'uptolike_shortcode' );
722
-
723
- function my_widgetcode_notice()
724
- {
725
- $options = get_option('my_option_name');
726
- if (is_array($options) && array_key_exists('widget_code', $options)) {
727
- $widget_code = $options['widget_code'];
728
- if ('' == $widget_code) {
729
- echo " <div class='updated'>
730
- <p>В настройках UpToLike 'Конструктор' выберите тип виджета и нажмите 'Сохранить'</p>
731
- </div>";
732
- }
733
- };
734
- }
735
-
736
- function logger($str)
737
- {
738
- file_put_contents(WP_PLUGIN_DIR . '/uptolike/log.txt', date(DATE_RFC822) . $str . PHP_EOL, FILE_APPEND | LOCK_EX);
739
- }
740
-
741
- function try_reg()
742
- {
743
- include('api_functions.php');
744
- $domain = preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
745
- $options = get_option('my_option_name');
746
- $email = $options['uptolike_email'];
747
- if ('' == $options['id_number']) {
748
- $reg_ans = userReg($email, 'cms', 'cms' . $domain);
749
- if (is_string($reg_ans)) {
750
- $my_options = get_option('my_option_name');
751
- $my_options['id_number'] = $reg_ans; // cryptkey store
752
- $my_options['choice'] = 'reg';
753
- update_option('my_option_name', $my_options);
754
- };
755
- update_option('reg_try', true);
756
- }
757
- }
758
-
759
- function my_choice_notice()
760
- {
761
- $options = get_option('my_option_name');
762
- if (is_bool($options) or (('' == $options['id_number']) and ((!array_key_exists('choice', $options)) OR ('ignore' !== $options['choice'])))) {
763
- echo "<div class='updated' style='
764
- background: #fff url(//uptolike.com/img/logo.png) no-repeat 2px;
765
- padding-left: 50px;
766
- padding-top: 15px;
767
- padding-bottom: 15px;'>Кнопки Uptolike успешно установлены! <a href='options-general.php?page=uptolike_settings&choice=ignore' style='float: right;'>Закрыть</a></div>";
768
- };
769
- }
770
-
771
- function set_default_code()
772
- {
773
- $options = get_option('my_option_name');
774
- if (is_bool($options)) {
775
- $options = array();
776
- }
777
- $domain = get_site_url();
778
- $domain = str_replace(array('http://','https://','.','-','www.'),'',$domain);
779
- $data_url = 'cms' . $_SERVER['HTTP_HOST'];
780
- $data_pid = 'cms'.$domain;
781
- $code = <<<EOD
782
- <script type="text/javascript">(function (w, doc) {
783
- if (!w.__utlWdgt) {
784
- w.__utlWdgt = true;
785
- var d = doc, s = d.createElement('script'), g = 'getElementsByTagName';
786
- s.type = 'text/javascript';
787
- s.charset = 'UTF-8';
788
- s.async = true;
789
- s.src = ('https:' == w.location.protocol ? 'https' : 'http') + '://w.uptolike.com/widgets/v1/uptolike.js';
790
- var h = d[g]('body')[0];
791
- h.appendChild(s);
792
- }
793
- })(window, document);
794
- </script>
795
- <div data-url data-background-alpha="0.0" data-orientation="horizontal" data-text-color="000000" data-share-shape="round-rectangle" data-buttons-color="ff9300" data-sn-ids="fb.tw.ok.vk.gp.mr." data-counter-background-color="ffffff" data-share-counter-size="11" data-share-size="30" data-background-color="ededed" data-share-counter-type="common" data-pid data-counter-background-alpha="1.0" data-share-style="1" data-mode="share" data-following-enable="false" data-like-text-enable="false" data-selection-enable="true" data-icon-color="ffffff" class="uptolike-buttons">
796
- </div>
797
- EOD;
798
-
799
- $code = str_replace('data-pid', 'data-pid="' . $data_pid . '"', $code);
800
- $code = str_replace('data-url', 'data-url="' . $data_url . '"', $code);
801
- $options['widget_code'] = $code;
802
- $options['on_main_static'] = 1;
803
- $options['on_main'] = 1;
804
- $options['on_page'] = 0;
805
- $options['on_special_pages'] = 1;
806
- $options['on_archive'] = 1;
807
- $options['widget_position'] = 'bottom';
808
- $options['widget_align'] = 'left';
809
- update_option('my_option_name', $options);
810
- }
811
-
812
- function choice_helper($choice)
813
- {
814
- $options = get_option('my_option_name');
815
- $options['choice'] = $choice;
816
- if ('ignore' == $choice) {
817
- set_default_code();
818
- }
819
- update_option('my_option_name', $options);
820
- }
821
-
822
- function usb_admin_actions()
823
- {
824
- if ( current_user_can('manage_options') ) {
825
- if (function_exists('add_meta_box')) {
826
- add_menu_page("UpToLike", "UpToLike", "manage_options", "UpToLike", 'my_custom_menu_page', plugins_url('uptolike-share/logo-small.png'));
827
- }
828
- }
829
- }
830
-
831
- function my_custom_menu_page(){
832
- include_once( 'usb-admin.php' );
833
- }
834
-
835
- function headeruptolike(){
836
- $options = get_option('my_option_name');
837
- if ($options['on_special_pages'] == 1) {
838
-
839
- //echo 'run on spec pages';
840
- $in_content = array(0,1);
841
- $in_fixed_block = array(2,3,4,5);
842
- $curr_value = json_decode($options['uptolike_json'])->orientation;
843
- if (in_array($curr_value,$in_content)) {
844
- // echo 'in content';
845
- } elseif (in_array($curr_value,$in_fixed_block)){
846
- if (is_page()) {//это страница
847
- if ($options['on_page'] == 1) echo get_widget_code();
848
- } elseif (is_archive()) {
849
- if ($options['on_archive'] == 1) echo get_widget_code();
850
- } elseif (is_front_page()) {
851
- if ($options['on_main'] == 1) echo get_widget_code();
852
- } else { echo get_widget_code();
853
- };
854
- //echo 'in_fixed_block';
855
- }
856
- }
857
- }
858
-
859
- class UptolikeWidget extends WP_Widget {
860
-
861
- function UptolikeWidget() {
862
- // Instantiate the parent object
863
- parent::__construct( false, 'Блок кнопок UpToLike' );
864
- }
865
-
866
- function widget( $args, $instance ) {
867
- echo get_widget_code();
868
- //echo 'uptolike widget';
869
- // Widget outputo
870
- }
871
-
872
- function update( $new_instance, $old_instance ) {
873
- // Save widget options
874
- }
875
-
876
- function form( $instance ) {
877
- // Output admin widget options form
878
- }
879
- }
880
-
881
- function uptolike_register_widgets() {
882
- register_widget( 'UptolikeWidget' );
883
- }
884
-
885
- register_activation_hook(__FILE__,'usb_admin_actions');
886
-
887
- add_action( 'widgets_init', 'uptolike_register_widgets' );
888
- add_action('wp_footer', 'headeruptolike', 1);
889
- add_action('admin_notices', 'my_choice_notice');
890
- add_action('admin_notices', 'my_widgetcode_notice');
891
- add_action('admin_menu', 'usb_admin_actions');
892
-
893
- $options = get_option('my_option_name');
894
-
895
- if (is_admin()) {
896
- $options = get_option('my_option_name');
897
- if (array_key_exists('regme', $_REQUEST)) {
898
- try_reg();
899
- }
900
- if (array_key_exists('choice', $_REQUEST)) {
901
- choice_helper($_REQUEST['choice']);
902
- }
903
- $my_settings_page = new MySettingsPage();
904
- if (is_bool($options) OR (!array_key_exists('widget_code', $options)) OR ('' == $options['widget_code'])) {
905
- set_default_code();
906
- }
907
- }
1
+ <?php
2
+
3
+ class MySettingsPage {
4
+ public $options;
5
+ public $settings_page_name = 'uptolike_settings';
6
+
7
+ public function __construct() {
8
+ add_action('admin_menu', array($this, 'add_plugin_page'));
9
+ add_action('admin_init', array($this, 'page_init'));
10
+ $this->options = get_option('uptolike_options');
11
+ }
12
+
13
+ public function add_plugin_page() {
14
+ add_options_page('Settings Admin', 'UpToLike', 'manage_options', $this->settings_page_name, //'my-setting-admin',
15
+ array($this, 'create_admin_page'));
16
+ }
17
+
18
+ /** creates url of iframe with statistics page from given params
19
+ *
20
+ * @param $projectId
21
+ * @param $partnerId
22
+ * @param $mail
23
+ * @param $cryptKey
24
+ *
25
+ * @return stringшfr
26
+ */
27
+ public function statIframe($projectId, $partnerId, $mail, $cryptKey) {
28
+ $params = array('mail' => $mail, 'partner' => $partnerId, 'projectId' => $projectId,
29
+
30
+ );
31
+ $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId . '&projectId=' . $projectId;
32
+ $signature = md5($paramsStr . $cryptKey);
33
+ $params['signature'] = $signature;
34
+ $finalUrl = 'https://uptolike.com/api/statistics.html?' . http_build_query($params);
35
+
36
+ return $finalUrl;
37
+ }
38
+
39
+ /** create url of iframe with constructor from given params
40
+ *
41
+ * @param $projectId
42
+ * @param $partnerId
43
+ * @param $mail
44
+ * @param $cryptKey
45
+ *
46
+ * @return string
47
+ */
48
+ public function constructorIframe($projectId, $partnerId, $mail, $cryptKey) {
49
+ $params = array('mail' => $mail, 'partner' => $partnerId, 'projectId' => $projectId);
50
+
51
+ $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId . '&projectId=' . $projectId . $cryptKey;
52
+ $signature = md5($paramsStr);
53
+ $params['signature'] = $signature;
54
+ if ('' !== $cryptKey) {
55
+ $finalUrl = 'https://uptolike.com/api/constructor.html?' . http_build_query($params);
56
+ } else $finalUrl = 'https://uptolike.com/api/constructor.html';
57
+ return $finalUrl;
58
+ }
59
+
60
+ /** returns tabs html code. May be replace by proper html code
61
+ *
62
+ * @param string $current
63
+ */
64
+ public function ilc_admin_tabs($current = 'construct') {
65
+ $tabs = array('construct' => 'Конструктор', 'stat' => 'Статистика', 'settings' => 'Настройки');
66
+
67
+ echo '<div id="icon-themes" class="icon32"><br></div>';
68
+ echo '<h2 class="nav-tab-wrapper">';
69
+ foreach ($tabs as $tab => $name) {
70
+ $class = ($tab == $current) ? ' nav-tab-active' : '';
71
+ echo "<a class='nav-tab$class' href='#' id=" . $tab . " ref='?page=" . $this->settings_page_name . "&tab=$tab'>$name</a>";
72
+ }
73
+ echo '</h2>';
74
+ }
75
+
76
+ /** render html page with code configuration settings
77
+ */
78
+ public function create_admin_page() {
79
+ $this->options = get_option('uptolike_options');
80
+ if ((isset($this->options['uptolike_email'])) && ('' !== $this->options['uptolike_email'])) {
81
+ $email = $this->options['uptolike_email'];
82
+ } else $email = get_option('admin_email');
83
+ $partnerId = 'cms';
84
+ $projectId = 'cms' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
85
+ $projectId = str_replace('.', '', $projectId);
86
+ $projectId = str_replace('-', '', $projectId);
87
+ $options = get_option('uptolike_options');
88
+ if (is_array($options) && array_key_exists('id_number', $options)) {
89
+ $cryptKey = $options['id_number'];
90
+ } else $cryptKey = '';
91
+ ?>
92
+ <script type="text/javascript">
93
+ <?php include('js/main.js'); ?>
94
+ </script>
95
+ <style type="text/css">
96
+ <?php include('css/uptolike_style.css')?>
97
+ </style>
98
+ <div id="uptolike_site_url" style="display: none"><?php echo get_site_url(); ?></div>
99
+ <div class="wrap">
100
+ <h2 class="placeholder">&nbsp;</h2>
101
+
102
+ <div id="wrapper">
103
+ <form id="settings_form" method="post" action="options.php">
104
+ <h1> UpToLike виджет</h1>
105
+
106
+ <h2 class="nav-tab-wrapper">
107
+ <a class="nav-tab nav-tab-active" href="#" id="construct">
108
+ Конструктор
109
+ </a>
110
+ <a class="nav-tab" href="#" id="stat">
111
+ Статистика
112
+ </a>
113
+ <a class="nav-tab" href="#" id="settings">
114
+ Настройки
115
+ </a>
116
+ </h2>
117
+
118
+ <div class="wrapper-tab active" id="con_construct">
119
+ <iframe id='cons_iframe' style='height: 445px;width: 100%;'
120
+ data-src="<?php echo $this->constructorIframe($projectId, $partnerId, $email, $cryptKey); ?>"></iframe>
121
+ <br>
122
+ <a onclick="getCode();" href="#">
123
+ <button type="reset">Сохранить изменения</button>
124
+ </a>
125
+ </div>
126
+ <div class="wrapper-tab" id="con_stat">
127
+ <iframe style="width: 100%;height: 380px;" id="stats_iframe"
128
+ data-src="<?php echo $this->statIframe($projectId, $partnerId, $email, $cryptKey); ?>">
129
+ </iframe>
130
+ <div id="before_key_req">Введите ваш адрес электронной почты для получения
131
+ ключа.
132
+ </div>
133
+ <div id="after_key_req">На ваш адрес электронной почты отправлен секретный
134
+ ключ. Введите его в поле ниже<br/>
135
+ Если письмо с ключом долго не приходит, возможно оно попало в Спам.<br/><br/>
136
+ Если ключ так и не был получен напишите письмо в службу поддержки: <a
137
+ href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a><br/>
138
+ В письме пришлите, пожалуйста, адрес вашего сайта и адрес электронной
139
+ почты, указанный в плагине.<br/>
140
+ </div>
141
+ <table>
142
+ <tr id="email_tr">
143
+ <td>Email:</td>
144
+ <td><input type="text" id="uptolike_email_field"></td>
145
+ </tr>
146
+ <tr id="cryptkey_field">
147
+ <td>Ключ:</td>
148
+ <td><input type="text" id="uptolike_cryptkey"></td>
149
+ </tr>
150
+ <tr id="get_key_btn_field">
151
+ <td></td>
152
+ <td>
153
+ <button id="get_key" type="button"> Получить ключ</button>
154
+ </td>
155
+ </tr>
156
+ <tr id="bad_key_field">
157
+ <td colspan="2">Введен неверный ключ! Убедитесь что вы скопировали
158
+ ключ без лишних символов (пробелов и т.д.)
159
+ </td>
160
+ </tr>
161
+ <tr id="foreignAccess_field">
162
+ <td colspan="2">Данный проект принадлежит другому пользователю.
163
+ Обратитесь в службу поддержки
164
+ </td>
165
+ </tr>
166
+ <tr id="key_auth_field">
167
+ <td></td>
168
+ <td>
169
+ <button id="auth" type="button"> Авторизация</button>
170
+ </td>
171
+ </tr>
172
+ </table>
173
+ <div>Обратная связь: <a href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a>
174
+ </div>
175
+ </div>
176
+ <div class="wrapper-tab" id="con_settings">
177
+ <div class="utl_left_block">
178
+ <?php
179
+ settings_fields('my_option_group');
180
+ do_settings_sections('uptolike_settings');
181
+ ?>
182
+ <input type="submit" name="submit_btn" value="Cохранить изменения">
183
+ <br>
184
+ </div>
185
+ <div class="utl_right_block">
186
+ <div class="utl_blok1">
187
+ <div class="utl_blok2">
188
+ <div class="utl_logo utl_i_logo">
189
+ </div>
190
+ </div>
191
+ <div class="utl_innertext">Для вставки шорткода в .php файл шаблона
192
+ нужно использовать конструкцию
193
+ <br><b><i>
194
+ &lt;?php echo do_shortcode("[uptolike]"); ?&gt;<br></i></b>
195
+ Для вставки в режиме визуального редактора достаточно
196
+ вставить<b> <i>[uptolike]</i></b>.
197
+ </div>
198
+ </div>
199
+ <div class="utl_blok1">
200
+ <div class="utl_blok2">
201
+ <div class="utl_logo utl_like_logo">
202
+ </div>
203
+ </div>
204
+ <div class="utl_innertext">Данный плагин полностью бесплатен. Мы
205
+ регулярно его улучшаем и добавляем новые функции.<br>
206
+ Пожалуйста, оставьте свой отзыв на <a
207
+ href="https://wordpress.org/support/view/plugin-reviews/uptolike-share">данной
208
+ странице</a>. Спасибо! <br>
209
+ </div>
210
+ </div>
211
+ <div class="utl_blok1">
212
+ <div class="utl_blok2">
213
+ <div class="utl_logo utl_mail_logo">
214
+ </div>
215
+ </div>
216
+ <div class="utl_innertext"><a
217
+ href="http://uptolike.ru">Uptolike.ru</a> &mdash; конструктор
218
+ социальных кнопок для вашего сайта с расширенным
219
+ функционалом.<br>
220
+ Служба поддержки: <a
221
+ href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a>
222
+ </div>
223
+ </div>
224
+ </div>
225
+
226
+ </div>
227
+ </form>
228
+ </div>
229
+ </div>
230
+ <?php
231
+ }
232
+
233
+ public function page_init() {
234
+ register_setting('my_option_group', 'uptolike_options', array($this, 'sanitize'));
235
+
236
+ add_settings_section('setting_section_id', 'Настройки отображения блока Uptolike', array($this, 'print_section_info'), $this->settings_page_name);
237
+
238
+ add_settings_field('widget_code', 'код виджета', // Title
239
+ array($this, 'widget_code_callback'), $this->settings_page_name, 'setting_section_id');
240
+
241
+ add_settings_field('data_pid', 'Ключ(CryptKey)', array($this, 'id_number_callback'), $this->settings_page_name, 'setting_section_id');
242
+
243
+ add_settings_field('email', //ID
244
+ 'email для регистрации', array($this, 'uptolike_email_callback'), $this->settings_page_name, 'setting_section_id');
245
+
246
+ add_settings_field('on_main', //ID
247
+ 'На главной странице ', array($this, 'uptolike_on_main_callback'), $this->settings_page_name, 'setting_section_id');
248
+
249
+ add_settings_field('on_page', //ID
250
+ 'На статических страницах', array($this, 'uptolike_on_page_callback'), $this->settings_page_name, 'setting_section_id');
251
+
252
+ add_settings_field('on_post', //ID
253
+ 'На страницах записей', array($this, 'uptolike_on_post_callback'), $this->settings_page_name, 'setting_section_id');
254
+
255
+ add_settings_field('on_archive', //ID
256
+ 'На страницах архивов', array($this, 'uptolike_on_archive_callback'), $this->settings_page_name, 'setting_section_id');
257
+
258
+ add_settings_field('on_special_pages', //ID
259
+ 'На спец. страницах <p class="utl_quest"><img class="utl_quest" src="/wp-content/plugins/uptolike-share/images/quest.png"><span class="utl_quest">Отображение блока кнопок на страницах, созданных плагинами (WooCommerce, WP-Shop и т.д.)</span></p>', array($this, 'uptolike_on_special_pages_callback'), $this->settings_page_name, 'setting_section_id');
260
+
261
+ add_settings_field('widget_position', //ID
262
+ 'Расположение блока', array($this, 'uptolike_widget_position_callback'), $this->settings_page_name, 'setting_section_id');
263
+
264
+ add_settings_field('widget_align', //ID
265
+ 'Выравнивание блока', array($this, 'uptolike_widget_align_callback'), $this->settings_page_name, 'setting_section_id');
266
+
267
+ add_settings_field('widget_mode', //ID
268
+ 'Режим работы', array($this, 'uptolike_widget_mode_callback'), $this->settings_page_name, 'setting_section_id');
269
+
270
+ add_settings_field('utl_language', //ID
271
+ 'Язык', array($this, 'uptolike_utl_language_callback'), $this->settings_page_name, 'setting_section_id');
272
+
273
+ add_settings_field('uptolike_json', //ID
274
+ 'настройки конструктора', array($this, 'uptolike_json_callback'), $this->settings_page_name, 'setting_section_id');
275
+ }
276
+
277
+ /**
278
+ * Sanitize each setting field as needed
279
+ *
280
+ * @param array $input Contains all settings fields as array keys
281
+ */
282
+ public function sanitize($input) {
283
+ $new_input = array();
284
+ if (isset($input['id_number'])) $new_input['id_number'] = str_replace(' ', '', $input['id_number']);
285
+
286
+ if (isset($input['widget_code'])) $new_input['widget_code'] = $input['widget_code'];
287
+
288
+ if (isset($input['uptolike_email'])) $new_input['uptolike_email'] = $input['uptolike_email'];
289
+
290
+ if (isset($input['before_content'])) $new_input['before_content'] = $input['before_content'];
291
+
292
+ if (isset($input['on_main'])) {
293
+ $new_input['on_main'] = 1;
294
+ } else $new_input['on_main'] = 0;
295
+
296
+ if (isset($input['on_page'])) {
297
+ $new_input['on_page'] = 1;
298
+ } else $new_input['on_page'] = 0;
299
+
300
+ if (isset($input['on_post'])) {
301
+ $new_input['on_post'] = 1;
302
+ } else $new_input['on_post'] = 0;
303
+
304
+ if (isset($input['on_special_pages'])) {
305
+ $new_input['on_special_pages'] = 1;
306
+ } else $new_input['on_special_pages'] = 0;
307
+
308
+ if (isset($input['on_archive'])) {
309
+ $new_input['on_archive'] = 1;
310
+ } else $new_input['on_archive'] = 0;
311
+
312
+ if (isset($input['email'])) $new_input['email'] = $input['email'];
313
+
314
+ if (isset($input['after_content'])) $new_input['after_content'] = $input['after_content'];
315
+
316
+ if (isset($input['widget_position'])) $new_input['widget_position'] = $input['widget_position'];
317
+
318
+ if (isset($input['widget_mode'])) $new_input['widget_mode'] = $input['widget_mode'];
319
+
320
+ if (isset($input['widget_align'])) $new_input['widget_align'] = $input['widget_align'];
321
+
322
+ if (isset($input['utl_language'])) $new_input['utl_language'] = $input['utl_language'];
323
+
324
+
325
+ if (isset($input['uptolike_json'])) $new_input['uptolike_json'] = $input['uptolike_json'];
326
+
327
+ return $new_input;
328
+ }
329
+
330
+
331
+ public function print_section_info() {
332
+ }
333
+
334
+ public function widget_code_callback() {
335
+ printf('<textarea id="widget_code" name="uptolike_options[widget_code]" >%s</textarea>', isset($this->options['widget_code']) ? esc_attr($this->options['widget_code']) : '');
336
+ }
337
+
338
+ /** 12536473050877
339
+ * Get the settings option array and print one of its values
340
+ */
341
+ public function id_number_callback() {
342
+ printf('<input type="text" class="id_number" name="uptolike_options[id_number]" value="%s" />', isset($this->options['id_number']) ? esc_attr($this->options['id_number']) : '');
343
+ }
344
+
345
+ public function uptolike_email_callback() {
346
+ printf('<input type="text" id="uptolike_email" name="uptolike_options[uptolike_email]" value="%s" />', isset($this->options['uptolike_email']) ? esc_attr($this->options['uptolike_email']) : '');
347
+ }
348
+
349
+ public function uptolike_json_callback() {
350
+ printf('<input type="hidden" id="uptolike_json" name="uptolike_options[uptolike_json]" value="%s" />', isset($this->options['uptolike_json']) ? esc_attr($this->options['uptolike_json']) : '');
351
+ }
352
+
353
+ public function uptolike_partner_id_callback() {
354
+ printf('<input type="text" id="uptolike_partner" name="uptolike_options[uptolike_partner]" value="%s" />', isset($this->options['uptolike_partner']) ? esc_attr($this->options['uptolike_partner']) : '');
355
+ }
356
+
357
+ public function uptolike_project_callback() {
358
+ printf('<input type="text" id="uptolike_project" name="uptolike_options[uptolike_project]" value="%s" />', isset($this->options['uptolike_project']) ? esc_attr($this->options['uptolike_project']) : '');
359
+ }
360
+
361
+ public function uptolike_on_main_callback() {
362
+ echo '<input type="checkbox" id="on_main" name="uptolike_options[on_main]"';
363
+ echo($this->options['on_main'] == '1' ? 'checked="checked"' : '');
364
+ echo '/>';
365
+ }
366
+
367
+ public function uptolike_on_page_callback() {
368
+ echo '<input type="checkbox" id="on_page" name="uptolike_options[on_page]"';
369
+ echo($this->options['on_page'] == '1' ? 'checked="checked"' : '');
370
+ echo '/>';
371
+ }
372
+
373
+ public function uptolike_on_post_callback() {
374
+ echo '<input type="checkbox" id="on_post" name="uptolike_options[on_post]"';
375
+ echo($this->options['on_post'] == '1' ? 'checked="checked"' : '');
376
+ echo '/>';
377
+ }
378
+
379
+ public function uptolike_on_special_pages_callback() {
380
+ echo '<input type="checkbox" id="on_special_pages" name="uptolike_options[on_special_pages]"';
381
+ echo($this->options['on_special_pages'] == '1' ? 'checked="checked"' : '');
382
+ echo '/>';
383
+ }
384
+
385
+ public function uptolike_on_archive_callback() {
386
+ echo '<input type="checkbox" id="on_archive" name="uptolike_options[on_archive]"';
387
+ echo($this->options['on_archive'] == '1' ? 'checked="checked"' : '');
388
+ echo '/>';
389
+ }
390
+
391
+ public function uptolike_widget_mode_callback() {
392
+ $plg_mode = $code_mode = $both_mode = '';
393
+
394
+ if (isset($this->options['widget_mode'])) {
395
+ if ($this->options['widget_mode'] == 'plg') {
396
+ $plg_mode = "selected='selected'";
397
+ } elseif ($this->options['widget_mode'] == 'code') {
398
+ $code_mode = "selected='selected'";
399
+ } elseif ($this->options['widget_mode'] == 'both') {
400
+ $both_mode = "selected='selected'";
401
+ }
402
+ } else {
403
+ $my_options = get_option('uptolike_options');
404
+ $my_options['widget_mode'] = 'plg'; // cryptkey store
405
+ update_option('uptolike_options', $my_options);
406
+ }
407
+ echo "<select id='widget_mode' name='uptolike_options[widget_mode]'>
408
+ <option {$plg_mode} value='plg'>Плагин</option>
409
+ <option {$code_mode} value='code'>Шорткод</option>
410
+ <option {$both_mode} value='both'>Плагин и шорткод</option>
411
+ </select>";
412
+ }
413
+
414
+ public function uptolike_widget_align_callback() {
415
+ $left = $right = $center = '';
416
+
417
+ if (isset($this->options['widget_align'])) {
418
+ if ('left' == $this->options['widget_align']) {
419
+ $left = "selected='selected'";
420
+ } elseif ('right' == $this->options['widget_align']) {
421
+ $right = "selected='selected'";
422
+ } elseif ('center' == $this->options['widget_align']) {
423
+ $center = "selected='selected'";
424
+ }
425
+ } else {
426
+ $my_options = get_option('uptolike_options');
427
+ $my_options['widget_align'] = 'left'; // cryptkey store
428
+ update_option('uptolike_options', $my_options);
429
+ }
430
+
431
+ echo "<select id='widget_align' name='uptolike_options[widget_align]'>
432
+ <option {$left} value='left'>По левому краю</option>
433
+ <option {$right} value='right'>По правому краю</option>
434
+ <option {$center} value='center'>По центру</option>
435
+ </select>";
436
+ }
437
+
438
+ public function uptolike_widget_position_callback() {
439
+ $top = $bottom = $both = '';
440
+
441
+ if (isset($this->options['widget_position'])) {
442
+ if ($this->options['widget_position'] == 'top') {
443
+ $top = "selected='selected'";
444
+ } elseif ($this->options['widget_position'] == 'bottom') {
445
+ $bottom = "selected='selected'";
446
+ } elseif ($this->options['widget_position'] == 'both') {
447
+ if (json_decode($this->options['uptolike_json'])->orientation < 2) {
448
+ $both = "selected='selected'";
449
+ } else {
450
+ $both = '';
451
+ $bottom = "selected='selected'";
452
+ $my_options = get_option('uptolike_options');
453
+ $my_options['widget_position'] = 'bottom'; // cryptkey store
454
+ update_option('uptolike_options', $my_options);
455
+ }
456
+ } else {
457
+ $bottom = "selected='selected'";
458
+ }
459
+ } else {
460
+ $my_options = get_option('uptolike_options');
461
+ $my_options['widget_position'] = 'bottom'; // cryptkey store
462
+ update_option('uptolike_options', $my_options);
463
+ }
464
+ echo "<select id='widget_position' name='uptolike_options[widget_position]'>
465
+ <option {$top} value='top'>Только сверху</option>
466
+ <option {$bottom} value='bottom'>Только снизу</option>";
467
+ if (json_decode($this->options['uptolike_json'])->orientation < 2) {
468
+ echo "<option {$both} value='both'>Сверху и снизу</option>";
469
+ }
470
+ echo "</select>";
471
+
472
+ }
473
+
474
+ public function uptolike_utl_language_callback() {
475
+ $ru = $en = $ua = $de = $es = $it = $pl = $lt = '';
476
+ if (isset($this->options['utl_language'])) {
477
+ if ($this->options['utl_language'] == 'ru') {
478
+ $ru = "selected='selected'";
479
+ } elseif ('en' == $this->options['utl_language']) {
480
+ $en = "selected='selected'";
481
+ } elseif ('ua' == $this->options['utl_language']) {
482
+ $ua = "selected='selected'";
483
+ } elseif ('de' == $this->options['utl_language']) {
484
+ $de = "selected='selected'";
485
+ } elseif ('es' == $this->options['utl_language']) {
486
+ $es = "selected='selected'";
487
+ } elseif ('it' == $this->options['utl_language']) {
488
+ $it = "selected='selected'";
489
+ } elseif ('pl' == $this->options['utl_language']) {
490
+ $pl = "selected='selected'";
491
+ } elseif ('lt' == $this->options['utl_language']) {
492
+ $lt = "selected='selected'";
493
+ } else {
494
+ $ru = "selected='selected'";
495
+ }
496
+ } else {
497
+ $my_options = get_option('uptolike_options');
498
+ $my_options['utl_language'] = 'ru'; // cryptkey store
499
+ update_option('uptolike_options', $my_options);
500
+ }
501
+ echo "<select id='widget_position' name='uptolike_options[utl_language]'>
502
+ <option {$ru} value='ru'>Русский</option>
503
+ <option {$en} value='en'>Английский</option>
504
+ <option {$ua} value='ua'>Украинский</option>
505
+ <option {$de} value='de'>Немецкий</option>
506
+ <option {$es} value='es'>Испанский</option>
507
+ <option {$it} value='it'>Итальянский</option>
508
+ <option {$pl} value='pl'>Латвийский</option>
509
+ <option {$lt} value='lt'>Польский</option>
510
+ </select>";
511
+ }
512
+ }
513
+
514
+ function get_widget_code($url = '') {
515
+ $options = get_option('uptolike_options');
516
+ $widget_code = $options['widget_code'];
517
+ $protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"], 0, strpos($_SERVER["SERVER_PROTOCOL"], '/'))) . '://';
518
+ if ($url == '') {
519
+ if (is_single() || is_page()) {
520
+ $url = get_permalink();
521
+ } else $url = $protocol . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
522
+ }
523
+ if ($_SERVER["REQUEST_URI"] == '/' && !(json_decode($options['uptolike_json'])->orientation < 2) && !empty(json_decode($options['uptolike_json'])->orientation)) {
524
+ $url = home_url('/');
525
+ }
526
+
527
+ $domain = preg_replace('/^www\./', '', get_site_url());
528
+ $data_pid = 'cms' . str_replace(array('https://', 'http://', '.', '-'), '', $domain);
529
+
530
+ $widget_code = str_replace('data-pid="-1"', 'data-pid="' . $data_pid . '"', $widget_code);
531
+ $widget_code = str_replace('data-pid=""', 'data-pid="' . $data_pid . '"', $widget_code);
532
+ $widget_code = str_replace('div data', 'div data-url="' . $url . '" del', $widget_code);//data-url duplicate
533
+ $widget_code = preg_replace('!del-url="(.*?)"!si', '', $widget_code);
534
+ $widget_code = str_replace('del-', '', $widget_code);
535
+ $align = $options['widget_align'];
536
+
537
+ $align_style = 'style="text-align: ' . $align . ';"';
538
+ $widget_code = str_replace('div data', 'div data-lang="' . $options['utl_language'] . '" data', $widget_code);
539
+ $widget_code = str_replace('<div ', '<div ' . $align_style . ' ', $widget_code);
540
+
541
+ return $widget_code;
542
+ }
543
+
544
+ function add_widget($content) {
545
+ global $post;
546
+ $options = get_option('uptolike_options');
547
+ $widget_mode = $options['widget_mode'];
548
+ if (is_array($options) && (($widget_mode == 'plg') or ($widget_mode == 'both')) && array_key_exists('widget_code', $options)) {
549
+ if ((!empty(json_decode($options['uptolike_json'])->orientation) && json_decode($options['uptolike_json'])->orientation < 2) || !(isset(json_decode($options['uptolike_json'])->orientation))) {
550
+ if (is_front_page() || is_home()) {
551
+ if ($options['on_main'] == 1 && (home_url('/') == request_home_url())) {
552
+ switch ($options['widget_position']) {
553
+ case 'both':
554
+ return get_widget_code(get_permalink()) . $content . get_widget_code(get_permalink());
555
+ case 'top':
556
+ return get_widget_code(get_permalink()) . $content;
557
+ case 'bottom':
558
+ return $content . get_widget_code(get_permalink());
559
+ }
560
+ } elseif ($options['on_main'] != 1 && (home_url('/') == request_home_url())) {
561
+ return $content;
562
+ }
563
+ } elseif (is_page() && $options['on_page'] == 1 && (home_url('/') != request_home_url())) {
564
+ switch ($options['widget_position']) {
565
+ case 'both':
566
+ return get_widget_code(get_permalink()) . $content . get_widget_code(get_permalink());
567
+ case 'top':
568
+ return get_widget_code(get_permalink()) . $content;
569
+ case 'bottom':
570
+ return $content . get_widget_code(get_permalink());
571
+ }
572
+ } elseif (is_single() && $options['on_post'] == 1 && (home_url('/') != request_home_url())) {
573
+ switch ($options['widget_position']) {
574
+ case 'both':
575
+ return get_widget_code(get_permalink()) . $content . get_widget_code(get_permalink());
576
+ case 'top':
577
+ return get_widget_code(get_permalink()) . $content;
578
+ case 'bottom':
579
+ return $content . get_widget_code(get_permalink());
580
+ }
581
+ } elseif (is_archive() && $options['on_archive'] == 1 && $options['on_post'] == 1) {
582
+ switch ($options['widget_position']) {
583
+ case 'both':
584
+ return get_widget_code(get_permalink()) . $content . get_widget_code(get_permalink());
585
+ case 'top':
586
+ return get_widget_code(get_permalink()) . $content;
587
+ case 'bottom':
588
+ return $content . get_widget_code(get_permalink());
589
+ }
590
+ }
591
+ return $content;
592
+ } else { //if vertical panel
593
+ if (is_front_page() || is_home()) {
594
+ if ($options['on_main'] == 1 && (home_url('/') == request_home_url())) {
595
+ return $content . get_widget_code();
596
+ } elseif ($options['on_main'] != 1 && (home_url('/') == request_home_url())) {
597
+ return $content;
598
+ }
599
+ } elseif (is_page()) {
600
+ if ($options['on_page'] == 1 && (home_url('/') != request_home_url())) {
601
+ return $content . get_widget_code();
602
+ } elseif ($options['on_page'] != 1) {
603
+ return $content;
604
+ }
605
+ } elseif (is_single()) {
606
+ if ($options['on_post'] == 1 && (home_url('/') != request_home_url())) {
607
+ return $content . get_widget_code();
608
+ } elseif ($options['on_post'] != 1) {
609
+ return $content;
610
+ }
611
+ } elseif (is_archive()) {
612
+ if ($options['on_archive'] == 1 && $options['on_post'] == 1 && (home_url('/') != request_home_url())) {
613
+ return $content . get_widget_code();
614
+ } elseif ($options['on_archive'] != 1) {
615
+ return $content;
616
+ }
617
+ } else { //if other page
618
+ return $content . get_widget_code();
619
+ }
620
+ }
621
+ return $content;
622
+ }
623
+ }
624
+
625
+ add_filter('the_content', 'add_widget', 100);
626
+
627
+ function uptolike_shortcode($atts) {
628
+ $options = get_option('uptolike_options');
629
+ $widget_mode = $options['widget_mode'];
630
+ if (($widget_mode == 'code') or ($widget_mode == 'both')) {
631
+ return get_widget_code();
632
+ };
633
+ return true;
634
+ }
635
+
636
+ add_shortcode('uptolike', 'uptolike_shortcode');
637
+
638
+ function my_widgetcode_notice() {
639
+ $options = get_option('uptolike_options');
640
+ if (is_array($options) && array_key_exists('widget_code', $options)) {
641
+ $widget_code = $options['widget_code'];
642
+ if ($widget_code == '') {
643
+ echo " <div class='updated'>
644
+ <p>Во вкладке 'Конструктор' плагина Uptolike настройте внешний вид кнопок и нажмите 'Сохранить изменения'</p>
645
+ </div>";
646
+ }
647
+ };
648
+ }
649
+
650
+ function try_reg() {
651
+ include('api_functions.php');
652
+ $domain = preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
653
+ $options = get_option('uptolike_options');
654
+ $email = $options['uptolike_email'];
655
+ if ('' == $options['id_number']) {
656
+ $reg_ans = userReg($email, 'cms', 'cms' . $domain);
657
+ if (is_string($reg_ans)) {
658
+ $my_options = get_option('uptolike_options');
659
+ $my_options['id_number'] = $reg_ans; // cryptkey store
660
+ $my_options['choice'] = 'reg';
661
+ update_option('uptolike_options', $my_options);
662
+ };
663
+ update_option('reg_try', true);
664
+ }
665
+ }
666
+
667
+ function my_choice_notice() {
668
+ $options = get_option('uptolike_options');
669
+ if (is_bool($options) or (('' == $options['id_number']) and ((!array_key_exists('choice', $options)) OR ('ignore' !== $options['choice'])))) {
670
+ echo "<div class='updated' style='
671
+ background: #fff url(//uptolike.com/img/logo.png) no-repeat 2px;
672
+ padding-left: 50px;
673
+ padding-top: 15px;
674
+ padding-bottom: 15px;'>Кнопки Uptolike успешно установлены! <a href='options-general.php?page=uptolike_settings&choice=ignore' style='float: right;'>Закрыть</a></div>";
675
+ };
676
+ }
677
+
678
+ function set_default_code() {
679
+ $options = get_option('uptolike_options');
680
+ if (is_bool($options)) {
681
+ $options = array();
682
+ }
683
+ $domain = get_site_url();
684
+ $domain = str_replace(array('http://', 'https://', '.', '-', 'www.'), '', $domain);
685
+ $data_pid = 'cms' . $domain;
686
+ $code = <<<EOD
687
+ <script type="text/javascript">(function (w, doc) {
688
+ if (!w.__utlWdgt) {
689
+ w.__utlWdgt = true;
690
+ var d = doc, s = d.createElement('script'), g = 'getElementsByTagName';
691
+ s.type = 'text/javascript';
692
+ s.charset = 'UTF-8';
693
+ s.async = true;
694
+ s.src = ('https:' == w.location.protocol ? 'https' : 'http') + '://w.uptolike.com/widgets/v1/uptolike.js';
695
+ var h = d[g]('body')[0];
696
+ h.appendChild(s);
697
+ }
698
+ })(window, document);
699
+ </script>
700
+ <div data-url data-background-alpha="0.0" data-orientation="horizontal" data-text-color="000000" data-share-shape="round-rectangle" data-buttons-color="ff9300" data-sn-ids="fb.tw.ok.vk.gp.mr." data-counter-background-color="ffffff" data-share-counter-size="11" data-share-size="30" data-background-color="ededed" data-share-counter-type="common" data-pid data-counter-background-alpha="1.0" data-share-style="1" data-mode="share" data-following-enable="false" data-like-text-enable="false" data-selection-enable="true" data-icon-color="ffffff" class="uptolike-buttons">
701
+ </div>
702
+ EOD;
703
+ $code = str_replace('data-pid', 'data-pid="' . $data_pid . '"', $code);
704
+ $options['widget_code'] = $code;
705
+ $options['on_main'] = 1;
706
+ $options['on_page'] = 1;
707
+ $options['on_post'] = 1;
708
+ $options['on_special_pages'] = 1;
709
+ $options['on_archive'] = 1;
710
+ $options['widget_position'] = 'bottom';
711
+ $options['widget_mode'] = 'plg';
712
+ $options['widget_align'] = 'left';
713
+ $options['utl_language'] = 'ru';
714
+ update_option('uptolike_options', $options);
715
+ }
716
+
717
+ function choice_helper($choice) {
718
+ $options = get_option('uptolike_options');
719
+ $options['choice'] = $choice;
720
+ if ('ignore' == $choice) {
721
+ set_default_code();
722
+ }
723
+ update_option('uptolike_options', $options);
724
+ }
725
+
726
+ function usb_admin_actions() {
727
+ if (current_user_can('manage_options')) {
728
+ if (function_exists('add_meta_box')) {
729
+ add_menu_page("UpToLike", "UpToLike", "manage_options", "UpToLike", 'my_custom_menu_page', plugins_url('uptolike-share/images/logo-small.png'));
730
+ }
731
+ }
732
+ }
733
+
734
+ function my_custom_menu_page() {
735
+ include_once('usb-admin.php');
736
+ }
737
+
738
+ function request_home_url($url = '') {
739
+ $result = '';
740
+ $default_port = 80;
741
+ if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) {
742
+ $result .= 'https://';
743
+ $default_port = 443;
744
+ } else {
745
+ $result .= 'http://';
746
+ }
747
+ $result .= $_SERVER['SERVER_NAME'];
748
+ if ($_SERVER['SERVER_PORT'] != $default_port) {
749
+ $result .= ':' . $_SERVER['SERVER_PORT'];
750
+ }
751
+ $result .= $_SERVER['REQUEST_URI'];
752
+ if ($url) {
753
+ $result .= $url;
754
+ }
755
+ return $result;
756
+ }
757
+
758
+
759
+ class UptolikeWidget extends WP_Widget {
760
+
761
+ function UptolikeWidget() {
762
+ parent::__construct(false, 'Блок кнопок UpToLike');
763
+ }
764
+
765
+ function widget($args, $instance) {
766
+ }
767
+
768
+ function update($new_instance, $old_instance) {
769
+ }
770
+
771
+ function form($instance) {
772
+ }
773
+ }
774
+
775
+ function uptolike_register_widgets() {
776
+ register_widget('UptolikeWidget');
777
+ }
778
+
779
+ register_activation_hook(__FILE__, 'usb_admin_actions');
780
+
781
+ add_action('widgets_init', 'uptolike_register_widgets');
782
+ add_action('admin_notices', 'my_choice_notice');
783
+ add_action('admin_notices', 'my_widgetcode_notice');
784
+ add_action('admin_menu', 'usb_admin_actions');
785
+
786
+ if (is_admin()) {
787
+ $options = get_option('uptolike_options');
788
+ if (array_key_exists('regme', $_REQUEST)) {
789
+ try_reg();
790
+ }
791
+ if (array_key_exists('choice', $_REQUEST)) {
792
+ choice_helper($_REQUEST['choice']);
793
+ }
794
+ $my_settings_page = new MySettingsPage();
795
+ if (is_bool($options) OR (!array_key_exists('widget_code', $options)) OR ($options['widget_code'] == '')) {
796
+ set_default_code();
797
+ }
798
+ }