Uptolike Social Share Buttons - Version 1.5.9

Version Description

  • https
Download this release

Release Info

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

Code changes from version 1.5.8 to 1.5.9

Files changed (3) hide show
  1. readme.txt +7 -4
  2. uptolike_share_widget.php +8 -6
  3. widget_options.php +191 -87
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: Uptolike Team
3
  Tags: +1, UpToLike, AddThis, social buttons, bookmark, bookmarking, like, share, share button, sharing, social bookmarking, social bookmarks, кнопки соцсетей, социальные кнопки
4
  Requires at least: 3.0.1
5
- Tested up to: 4.7.3
6
- Stable tag: 1.5.8
7
 
8
  Uptolike Social Share Buttons - social bookmarking widget with sharing statistics.
9
 
@@ -107,14 +107,17 @@ Answers to Frequently Asked Questions you can find at http://uptolike.ru/faq
107
  3. Traffic and sharing statistics
108
 
109
  == Changelog ==
 
 
 
110
  = 1.5.8 =
111
  * Добавлен перевод на Чешский язык.
112
 
113
  = 1.5.7 =
114
- * Исправленна генерация ссылок при расположении виджета Боковой панелью.
115
 
116
  = 1.5.6 =
117
- * Корректное восстановление настроек плагина из предыдущих версий.
118
 
119
  = 1.5.5 =
120
  * Исправлен вывод UpToLike для страниц записей и статических страниц
2
  Contributors: Uptolike Team
3
  Tags: +1, UpToLike, AddThis, social buttons, bookmark, bookmarking, like, share, share button, sharing, social bookmarking, social bookmarks, кнопки соцсетей, социальные кнопки
4
  Requires at least: 3.0.1
5
+ Tested up to: 4.7.4
6
+ Stable tag: 1.5.9
7
 
8
  Uptolike Social Share Buttons - social bookmarking widget with sharing statistics.
9
 
107
  3. Traffic and sharing statistics
108
 
109
  == Changelog ==
110
+ = 1.5.9 =
111
+ * Исправленна генерация ссылок для защищённых сайтов с протоколом https
112
+
113
  = 1.5.8 =
114
  * Добавлен перевод на Чешский язык.
115
 
116
  = 1.5.7 =
117
+ * Исправленна генерация ссылок при расположении виджета Боковой панелью
118
 
119
  = 1.5.6 =
120
+ * Корректное восстановление настроек плагина из предыдущих версий
121
 
122
  = 1.5.5 =
123
  * Исправлен вывод UpToLike для страниц записей и статических страниц
uptolike_share_widget.php CHANGED
@@ -3,9 +3,9 @@
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.5.8
7
  * Requires at least: 4.1
8
- * Tested up to: 4.7.3
9
  * Author: Uptolike Team
10
  * Author URI: https://uptolike.com/
11
  *
@@ -19,7 +19,8 @@ include 'widget_options.php';
19
  add_filter('plugin_action_links', 'uptolike_action_links', 10, 2);
20
 
21
  function uptolike_action_links($links, $file) {
22
- if (false === strpos($file, basename(__FILE__))) return $links;
 
23
  $links[] = '<a href="' . add_query_arg(array('page' => 'uptolike_settings'), admin_url('plugins.php')) . '">' . __('Settings') . '</a>';
24
  return $links;
25
  }
@@ -27,13 +28,14 @@ function uptolike_action_links($links, $file) {
27
  add_filter('plugin_row_meta', 'uptolike_description_links', 10, 4);
28
 
29
  function uptolike_description_links($links, $file) {
30
- if (false === strpos($file, basename(__FILE__))) return $links;
 
31
  $links[] = '<a href="' . add_query_arg(array('page' => 'uptolike_settings'), admin_url('plugins.php')) . '">' . __('Settings') . '</a>';
32
  return $links;
33
  }
34
 
35
- register_activation_hook( __FILE__, 'uptolike_install' );
36
- register_uninstall_hook( __FILE__, 'uptolike_delete_plugin' );
37
 
38
  function uptolike_delete_plugin() {
39
  $delete = get_option('uptolike_options');
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.5.9
7
  * Requires at least: 4.1
8
+ * Tested up to: 4.7.4
9
  * Author: Uptolike Team
10
  * Author URI: https://uptolike.com/
11
  *
19
  add_filter('plugin_action_links', 'uptolike_action_links', 10, 2);
20
 
21
  function uptolike_action_links($links, $file) {
22
+ if (false === strpos($file, basename(__FILE__)))
23
+ return $links;
24
  $links[] = '<a href="' . add_query_arg(array('page' => 'uptolike_settings'), admin_url('plugins.php')) . '">' . __('Settings') . '</a>';
25
  return $links;
26
  }
28
  add_filter('plugin_row_meta', 'uptolike_description_links', 10, 4);
29
 
30
  function uptolike_description_links($links, $file) {
31
+ if (false === strpos($file, basename(__FILE__)))
32
+ return $links;
33
  $links[] = '<a href="' . add_query_arg(array('page' => 'uptolike_settings'), admin_url('plugins.php')) . '">' . __('Settings') . '</a>';
34
  return $links;
35
  }
36
 
37
+ register_activation_hook(__FILE__, 'uptolike_install');
38
+ register_uninstall_hook(__FILE__, 'uptolike_delete_plugin');
39
 
40
  function uptolike_delete_plugin() {
41
  $delete = get_option('uptolike_options');
widget_options.php CHANGED
@@ -12,10 +12,13 @@ class UptolikeSettingsPage {
12
  update_option('uptolike_options', $this->options);
13
  delete_option('my_option_name');
14
  }
15
- $this->options = get_option('uptolike_options'); }
 
16
 
17
  public function uptolike_add_plugin_page() {
18
- add_options_page('UpToLike Settings', 'UpToLike', 'manage_options', $this->settings_page_name, array($this, 'uptolike_create_admin_page'));
 
 
19
  }
20
 
21
  /** creates url of iframe with statistics page from given params
@@ -28,7 +31,10 @@ class UptolikeSettingsPage {
28
  * @return string
29
  */
30
  public function uptolike_statIframe($projectId, $partnerId, $mail, $cryptKey) {
31
- $params = array('mail' => $mail, 'partner' => $partnerId, 'projectId' => $projectId,
 
 
 
32
 
33
  );
34
  $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId . '&projectId=' . $projectId;
@@ -56,7 +62,8 @@ class UptolikeSettingsPage {
56
  $params['signature'] = $signature;
57
  if ('' !== $cryptKey) {
58
  $finalUrl = 'https://uptolike.com/api/constructor.html?' . http_build_query($params);
59
- } else $finalUrl = 'https://uptolike.com/api/constructor.html';
 
60
  return $finalUrl;
61
  }
62
 
@@ -82,7 +89,8 @@ class UptolikeSettingsPage {
82
  $this->options = get_option('uptolike_options');
83
  if ((isset($this->options['uptolike_email'])) && ('' !== $this->options['uptolike_email'])) {
84
  $email = $this->options['uptolike_email'];
85
- } else $email = get_option('admin_email');
 
86
  $partnerId = 'cms';
87
  $projectId = 'cms' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
88
  $projectId = str_replace('.', '', $projectId);
@@ -90,7 +98,8 @@ class UptolikeSettingsPage {
90
  $options = get_option('uptolike_options');
91
  if (is_array($options) && array_key_exists('id_number', $options)) {
92
  $cryptKey = $options['id_number'];
93
- } else $cryptKey = '';
 
94
  ?>
95
  <script type="text/javascript">
96
  <?php include('js/main.js'); ?>
@@ -136,7 +145,7 @@ class UptolikeSettingsPage {
136
  ключ. Введите его в поле ниже<br/>
137
  Если письмо с ключом долго не приходит, возможно оно попало в Спам.<br/><br/>
138
  Если ключ так и не был получен напишите письмо в службу поддержки: <a
139
- href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a><br/>
140
  В письме пришлите, пожалуйста, адрес вашего сайта и адрес электронной
141
  почты, указанный в плагине.<br/>
142
  </div>
@@ -208,7 +217,7 @@ class UptolikeSettingsPage {
208
  <div class="utl_innertext">Данный плагин полностью бесплатен. Мы
209
  регулярно его улучшаем и добавляем новые функции.<br>
210
  Пожалуйста, оставьте свой отзыв на <a
211
- href="https://wordpress.org/support/view/plugin-reviews/uptolike-share">данной
212
  странице</a>. Спасибо! <br>
213
  </div>
214
  </div>
@@ -219,11 +228,11 @@ class UptolikeSettingsPage {
219
  </div>
220
  </div>
221
  <div class="utl_innertext"><a
222
- href="http://uptolike.ru">Uptolike.ru</a> &mdash; конструктор
223
  социальных кнопок для вашего сайта с расширенным
224
  функционалом.<br>
225
  Служба поддержки: <a
226
- href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a>
227
  </div>
228
  </div>
229
  </div>
@@ -238,34 +247,60 @@ class UptolikeSettingsPage {
238
  public function uptolike_page_init() {
239
  register_setting('my_option_group', 'uptolike_options', array($this, 'uptolike_sanitize'));
240
 
241
- add_settings_section('setting_section_id', 'Настройки отображения блока Uptolike', array($this, 'uptolike_print_section_info'), $this->settings_page_name);
 
 
242
 
243
  add_settings_field('widget_code', 'код виджета', // Title
244
  array($this, 'uptolike_widget_code_callback'), $this->settings_page_name, 'setting_section_id');
245
 
246
- add_settings_field('data_pid', 'Ключ(CryptKey)', array($this, 'uptolike_id_number_callback'), $this->settings_page_name, 'setting_section_id');
 
 
247
 
248
- add_settings_field('email', 'email для регистрации', array($this, 'uptolike_email_callback'), $this->settings_page_name, 'setting_section_id');
 
 
249
 
250
- add_settings_field('on_main', 'На главной странице ', array($this, 'uptolike_on_main_callback'), $this->settings_page_name, 'setting_section_id');
 
 
251
 
252
- add_settings_field('on_page', 'На статических страницах', array($this, 'uptolike_on_page_callback'), $this->settings_page_name, 'setting_section_id');
 
 
253
 
254
- add_settings_field('on_post', 'На страницах записей', array($this, 'uptolike_on_post_callback'), $this->settings_page_name, 'setting_section_id');
 
 
255
 
256
- add_settings_field('on_archive', 'На страницах архивов', array($this, 'uptolike_on_archive_callback'), $this->settings_page_name, 'setting_section_id');
 
 
257
 
258
- add_settings_field('on_special_pages', 'На спец. страницах <p class="utl_quest"><img class="utl_quest" src="' . plugin_dir_url(__FILE__) . '/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');
 
 
259
 
260
- add_settings_field('widget_position', 'Расположение блока', array($this, 'uptolike_widget_position_callback'), $this->settings_page_name, 'setting_section_id');
 
 
261
 
262
- add_settings_field('widget_align', 'Выравнивание блока', array($this, 'uptolike_widget_align_callback'), $this->settings_page_name, 'setting_section_id');
 
 
263
 
264
- add_settings_field('widget_mode', 'Режим работы', array($this, 'uptolike_widget_mode_callback'), $this->settings_page_name, 'setting_section_id');
 
 
265
 
266
- add_settings_field('utl_language', 'Язык', array($this, 'uptolike_language_callback'), $this->settings_page_name, 'setting_section_id');
 
 
267
 
268
- add_settings_field('uptolike_json', 'настройки конструктора', array($this, 'uptolike_json_callback'), $this->settings_page_name, 'setting_section_id');
 
 
269
  }
270
 
271
  /**
@@ -275,48 +310,64 @@ class UptolikeSettingsPage {
275
  */
276
  public function uptolike_sanitize($input) {
277
  $new_input = array();
278
- if (isset($input['id_number'])) $new_input['id_number'] = str_replace(' ', '', $input['id_number']);
 
279
 
280
- if (isset($input['widget_code'])) $new_input['widget_code'] = $input['widget_code'];
 
281
 
282
- if (isset($input['uptolike_email'])) $new_input['uptolike_email'] = $input['uptolike_email'];
 
283
 
284
- if (isset($input['before_content'])) $new_input['before_content'] = $input['before_content'];
 
285
 
286
  if (isset($input['on_main'])) {
287
  $new_input['on_main'] = 1;
288
- } else $new_input['on_main'] = 0;
 
289
 
290
  if (isset($input['on_page'])) {
291
  $new_input['on_page'] = 1;
292
- } else $new_input['on_page'] = 0;
 
293
 
294
  if (isset($input['on_post'])) {
295
  $new_input['on_post'] = 1;
296
- } else $new_input['on_post'] = 0;
 
297
 
298
  if (isset($input['on_special_pages'])) {
299
  $new_input['on_special_pages'] = 1;
300
- } else $new_input['on_special_pages'] = 0;
 
301
 
302
  if (isset($input['on_archive'])) {
303
  $new_input['on_archive'] = 1;
304
- } else $new_input['on_archive'] = 0;
 
305
 
306
- if (isset($input['email'])) $new_input['email'] = trim($input['email']);
 
307
 
308
- if (isset($input['after_content'])) $new_input['after_content'] = $input['after_content'];
 
309
 
310
- if (isset($input['widget_position'])) $new_input['widget_position'] = $input['widget_position'];
 
311
 
312
- if (isset($input['widget_mode'])) $new_input['widget_mode'] = $input['widget_mode'];
 
313
 
314
- if (isset($input['widget_align'])) $new_input['widget_align'] = $input['widget_align'];
 
315
 
316
- if (isset($input['utl_language'])) $new_input['utl_language'] = $input['utl_language'];
 
317
 
318
 
319
- if (isset($input['uptolike_json'])) $new_input['uptolike_json'] = $input['uptolike_json'];
 
320
 
321
  return $new_input;
322
  }
@@ -388,12 +439,15 @@ class UptolikeSettingsPage {
388
  if (isset($this->options['widget_mode'])) {
389
  if ($this->options['widget_mode'] == 'plg') {
390
  $plg_mode = "selected='selected'";
391
- } elseif ($this->options['widget_mode'] == 'code') {
 
392
  $code_mode = "selected='selected'";
393
- } elseif ($this->options['widget_mode'] == 'both') {
 
394
  $both_mode = "selected='selected'";
395
  }
396
- } else {
 
397
  $uptolike_options = get_option('uptolike_options');
398
  $uptolike_options['widget_mode'] = 'plg'; // cryptkey store
399
  update_option('uptolike_options', $uptolike_options);
@@ -411,12 +465,15 @@ class UptolikeSettingsPage {
411
  if (isset($this->options['widget_align'])) {
412
  if ('left' == $this->options['widget_align']) {
413
  $left = "selected='selected'";
414
- } elseif ('right' == $this->options['widget_align']) {
 
415
  $right = "selected='selected'";
416
- } elseif ('center' == $this->options['widget_align']) {
 
417
  $center = "selected='selected'";
418
  }
419
- } else {
 
420
  $uptolike_options = get_option('uptolike_options');
421
  $uptolike_options['widget_align'] = 'left'; // cryptkey store
422
  update_option('uptolike_options', $uptolike_options);
@@ -435,22 +492,27 @@ class UptolikeSettingsPage {
435
  if (isset($this->options['widget_position'])) {
436
  if ($this->options['widget_position'] == 'top') {
437
  $top = "selected='selected'";
438
- } elseif ($this->options['widget_position'] == 'bottom') {
 
439
  $bottom = "selected='selected'";
440
- } elseif ($this->options['widget_position'] == 'both') {
 
441
  if (json_decode($this->options['uptolike_json'])->orientation < 2) {
442
  $both = "selected='selected'";
443
- } else {
 
444
  $both = '';
445
  $bottom = "selected='selected'";
446
  $uptolike_options = get_option('uptolike_options');
447
  $uptolike_options['widget_position'] = 'bottom'; // cryptkey store
448
  update_option('uptolike_options', $uptolike_options);
449
  }
450
- } else {
 
451
  $bottom = "selected='selected'";
452
  }
453
- } else {
 
454
  $uptolike_options = get_option('uptolike_options');
455
  $uptolike_options['widget_position'] = 'bottom'; // cryptkey store
456
  update_option('uptolike_options', $uptolike_options);
@@ -470,26 +532,36 @@ class UptolikeSettingsPage {
470
  if (isset($this->options['utl_language'])) {
471
  if ($this->options['utl_language'] == 'ru') {
472
  $ru = "selected='selected'";
473
- } elseif ('en' == $this->options['utl_language']) {
 
474
  $en = "selected='selected'";
475
- } elseif ('ua' == $this->options['utl_language']) {
 
476
  $ua = "selected='selected'";
477
- } elseif ('de' == $this->options['utl_language']) {
 
478
  $de = "selected='selected'";
479
- } elseif ('es' == $this->options['utl_language']) {
 
480
  $es = "selected='selected'";
481
- } elseif ('it' == $this->options['utl_language']) {
 
482
  $it = "selected='selected'";
483
- } elseif ('pl' == $this->options['utl_language']) {
 
484
  $pl = "selected='selected'";
485
- } elseif ('lt' == $this->options['utl_language']) {
 
486
  $lt = "selected='selected'";
487
- } elseif ('cz' == $this->options['utl_language']) {
 
488
  $cz = "selected='selected'";
489
- } else {
 
490
  $ru = "selected='selected'";
491
  }
492
- } else {
 
493
  $uptolike_options = get_option('uptolike_options');
494
  $uptolike_options['utl_language'] = 'ru'; // cryptkey store
495
  update_option('uptolike_options', $uptolike_options);
@@ -511,9 +583,13 @@ class UptolikeSettingsPage {
511
  function uptolike_get_widget_code($url = '') {
512
  $options = get_option('uptolike_options');
513
  $widget_code = $options['widget_code'];
514
- $protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"], 0, strpos($_SERVER["SERVER_PROTOCOL"], '/'))) . '://';
 
 
 
 
515
  if ($url == '') {
516
- $url = $protocol . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
517
  }
518
 
519
  if ($_SERVER["REQUEST_URI"] == '/' && !(json_decode($options['uptolike_json'])->orientation < 2) && !empty(json_decode($options['uptolike_json'])->orientation)) {
@@ -549,9 +625,11 @@ function uptolike_add_widget($content) {
549
  case 'bottom':
550
  return $content . uptolike_get_widget_code(get_permalink());
551
  }
552
- } elseif ($options['on_main'] != 1 && (home_url('/') == request_home_url())) {
 
553
  return $content;
554
- } elseif ($options['on_page'] == 1 && home_url('/') != request_home_url()) {
 
555
  switch ($options['widget_position']) {
556
  case 'both':
557
  return uptolike_get_widget_code(get_permalink()) . $content . uptolike_get_widget_code(get_permalink());
@@ -561,7 +639,8 @@ function uptolike_add_widget($content) {
561
  return $content . uptolike_get_widget_code(get_permalink());
562
  }
563
  }
564
- } elseif (is_page() && $options['on_page'] == 1 && (home_url('/') != request_home_url())) {
 
565
  switch ($options['widget_position']) {
566
  case 'both':
567
  return uptolike_get_widget_code(get_permalink()) . $content . uptolike_get_widget_code(get_permalink());
@@ -570,7 +649,8 @@ function uptolike_add_widget($content) {
570
  case 'bottom':
571
  return $content . uptolike_get_widget_code(get_permalink());
572
  }
573
- } elseif (is_single() && $options['on_post'] == 1 && (home_url('/') != request_home_url())) {
 
574
  switch ($options['widget_position']) {
575
  case 'both':
576
  return uptolike_get_widget_code(get_permalink()) . $content . uptolike_get_widget_code(get_permalink());
@@ -579,7 +659,8 @@ function uptolike_add_widget($content) {
579
  case 'bottom':
580
  return $content . uptolike_get_widget_code(get_permalink());
581
  }
582
- } elseif (is_archive() && $options['on_archive'] == 1 && $options['on_post'] == 1) {
 
583
  switch ($options['widget_position']) {
584
  case 'both':
585
  return uptolike_get_widget_code(get_permalink()) . $content . uptolike_get_widget_code(get_permalink());
@@ -589,22 +670,27 @@ function uptolike_add_widget($content) {
589
  return $content . uptolike_get_widget_code(get_permalink());
590
  }
591
  }
592
- } else { //if vertical panel
 
593
  if (is_front_page() || is_home()) {
594
  if ($options['on_main'] == 1 && (home_url('/') == request_home_url())) {
595
  add_action('wp_footer', 'uptolike_header');
596
- } elseif ($options['on_page'] == 1 && home_url('/') != request_home_url()) {
 
597
  add_action('wp_footer', 'uptolike_header');
598
  }
599
- } elseif (is_page()) {
 
600
  if ($options['on_page'] == 1 && (home_url('/') != request_home_url())) {
601
  add_action('wp_footer', 'uptolike_header');
602
  }
603
- } elseif (is_single()) {
 
604
  if ($options['on_post'] == 1 && (home_url('/') != request_home_url())) {
605
  add_action('wp_footer', 'uptolike_header');
606
  }
607
- } elseif (is_archive()) {
 
608
  if ($options['on_archive'] == 1 && $options['on_post'] == 1 && (home_url('/') != request_home_url())) {
609
  add_action('wp_footer', 'uptolike_header');
610
  }
@@ -623,16 +709,21 @@ function uptolike_shortcode() {
623
  if (is_front_page() || is_home()) {
624
  if ($options['on_main'] == 1 && (home_url('/') == request_home_url())) {
625
  return uptolike_get_widget_code();
626
- } elseif ($options['on_main'] != 1 && (home_url('/') == request_home_url())) {
 
627
  return;
628
- } elseif ($options['on_page'] == 1 && home_url('/') != request_home_url()) {
 
629
  return uptolike_get_widget_code();
630
  }
631
- } elseif (is_page() && $options['on_page'] == 1 && (home_url('/') != request_home_url())) {
 
632
  return uptolike_get_widget_code();
633
- } elseif (is_single() && $options['on_post'] == 1 && (home_url('/') != request_home_url())) {
 
634
  return uptolike_get_widget_code();
635
- } elseif (is_archive() && $options['on_archive'] == 1 && $options['on_post'] == 1) {
 
636
  return uptolike_get_widget_code();
637
  }
638
  }
@@ -663,15 +754,20 @@ function uptolike_widgetcode_notice() {
663
  function uptolike_user_reg($email, $partnerId, $projectId) {
664
 
665
  if ($email !== '' && $partnerId !== '' && $projectId !== '') {
666
- $url = 'https://uptolike.com/api/getCryptKeyWithUserReg.json?' . http_build_query(array('email' => $email, 'partner' => $partnerId, 'projectId' => $projectId));
 
 
 
667
 
668
  $jsonAnswer = file_get_contents($url);
669
  if (false !== $jsonAnswer) {
670
  $answer = json_decode($jsonAnswer);
671
  return $answer->cryptKey;
672
- } else return $jsonAnswer;
 
673
 
674
- } else return 'one of params is empty';
 
675
  }
676
 
677
  function uptolike_try_reg() {
@@ -764,7 +860,9 @@ function uptolike_custom_menu_page() {
764
  wp_die(__('Plugin UpToLike has been installed incorrectly.'));
765
  }
766
  if (function_exists('add_plugins_page')) {
767
- add_plugins_page('UpToLike Settings', 'UpToLike', 'manage_options', basename(__FILE__), array(&$uptolike_settings_page, 'uptolike_create_admin_page'));
 
 
768
  }
769
  }
770
 
@@ -774,7 +872,8 @@ function request_home_url($url = '') {
774
  if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) {
775
  $result .= 'https://';
776
  $default_port = 443;
777
- } else {
 
778
  $result .= 'http://';
779
  }
780
  $result .= $_SERVER['SERVER_NAME'];
@@ -795,25 +894,30 @@ function uptolike_header() {
795
  $in_fixed_block = array(2, 3, 4, 5);
796
  $curr_value = json_decode($options['uptolike_json'])->orientation;
797
  if (in_array($curr_value, $in_content)) {
798
- } elseif (in_array($curr_value, $in_fixed_block)) {
 
799
  echo uptolike_get_widget_code();
800
  }
801
- } elseif ((home_url('/') != request_home_url()) && ($options['on_special_pages'] == 1 || $options['on_page'] == 1)) {
 
802
  $in_content = array(0, 1);
803
  $in_fixed_block = array(2, 3, 4, 5);
804
  $curr_value = json_decode($options['uptolike_json'])->orientation;
805
  if (in_array($curr_value, $in_content)) {
806
  echo uptolike_get_widget_code();
807
- } elseif (in_array($curr_value, $in_fixed_block)) {
 
808
  echo uptolike_get_widget_code();
809
  }
810
- } elseif ((home_url('/') != request_home_url()) && ($options['on_post'] == 1)) {
 
811
  $in_content = array(0, 1);
812
  $in_fixed_block = array(2, 3, 4, 5);
813
  $curr_value = json_decode($options['uptolike_json'])->orientation;
814
  if (in_array($curr_value, $in_content)) {
815
  echo uptolike_get_widget_code();
816
- } elseif (in_array($curr_value, $in_fixed_block)) {
 
817
  echo uptolike_get_widget_code();
818
  }
819
  }
12
  update_option('uptolike_options', $this->options);
13
  delete_option('my_option_name');
14
  }
15
+ $this->options = get_option('uptolike_options');
16
+ }
17
 
18
  public function uptolike_add_plugin_page() {
19
+ add_options_page('UpToLike Settings', 'UpToLike', 'manage_options', $this->settings_page_name, array(
20
+ $this,
21
+ 'uptolike_create_admin_page'));
22
  }
23
 
24
  /** creates url of iframe with statistics page from given params
31
  * @return string
32
  */
33
  public function uptolike_statIframe($projectId, $partnerId, $mail, $cryptKey) {
34
+ $params = array(
35
+ 'mail' => $mail,
36
+ 'partner' => $partnerId,
37
+ 'projectId' => $projectId,
38
 
39
  );
40
  $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId . '&projectId=' . $projectId;
62
  $params['signature'] = $signature;
63
  if ('' !== $cryptKey) {
64
  $finalUrl = 'https://uptolike.com/api/constructor.html?' . http_build_query($params);
65
+ }
66
+ else $finalUrl = 'https://uptolike.com/api/constructor.html';
67
  return $finalUrl;
68
  }
69
 
89
  $this->options = get_option('uptolike_options');
90
  if ((isset($this->options['uptolike_email'])) && ('' !== $this->options['uptolike_email'])) {
91
  $email = $this->options['uptolike_email'];
92
+ }
93
+ else $email = get_option('admin_email');
94
  $partnerId = 'cms';
95
  $projectId = 'cms' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
96
  $projectId = str_replace('.', '', $projectId);
98
  $options = get_option('uptolike_options');
99
  if (is_array($options) && array_key_exists('id_number', $options)) {
100
  $cryptKey = $options['id_number'];
101
+ }
102
+ else $cryptKey = '';
103
  ?>
104
  <script type="text/javascript">
105
  <?php include('js/main.js'); ?>
145
  ключ. Введите его в поле ниже<br/>
146
  Если письмо с ключом долго не приходит, возможно оно попало в Спам.<br/><br/>
147
  Если ключ так и не был получен напишите письмо в службу поддержки: <a
148
+ href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a><br/>
149
  В письме пришлите, пожалуйста, адрес вашего сайта и адрес электронной
150
  почты, указанный в плагине.<br/>
151
  </div>
217
  <div class="utl_innertext">Данный плагин полностью бесплатен. Мы
218
  регулярно его улучшаем и добавляем новые функции.<br>
219
  Пожалуйста, оставьте свой отзыв на <a
220
+ href="https://wordpress.org/support/view/plugin-reviews/uptolike-share">данной
221
  странице</a>. Спасибо! <br>
222
  </div>
223
  </div>
228
  </div>
229
  </div>
230
  <div class="utl_innertext"><a
231
+ href="http://uptolike.ru">Uptolike.ru</a> &mdash; конструктор
232
  социальных кнопок для вашего сайта с расширенным
233
  функционалом.<br>
234
  Служба поддержки: <a
235
+ href="mailto:uptolikeshare@gmail.com">uptolikeshare@gmail.com</a>
236
  </div>
237
  </div>
238
  </div>
247
  public function uptolike_page_init() {
248
  register_setting('my_option_group', 'uptolike_options', array($this, 'uptolike_sanitize'));
249
 
250
+ add_settings_section('setting_section_id', 'Настройки отображения блока Uptolike', array(
251
+ $this,
252
+ 'uptolike_print_section_info'), $this->settings_page_name);
253
 
254
  add_settings_field('widget_code', 'код виджета', // Title
255
  array($this, 'uptolike_widget_code_callback'), $this->settings_page_name, 'setting_section_id');
256
 
257
+ add_settings_field('data_pid', 'Ключ(CryptKey)', array(
258
+ $this,
259
+ 'uptolike_id_number_callback'), $this->settings_page_name, 'setting_section_id');
260
 
261
+ add_settings_field('email', 'email для регистрации', array(
262
+ $this,
263
+ 'uptolike_email_callback'), $this->settings_page_name, 'setting_section_id');
264
 
265
+ add_settings_field('on_main', 'На главной странице ', array(
266
+ $this,
267
+ 'uptolike_on_main_callback'), $this->settings_page_name, 'setting_section_id');
268
 
269
+ add_settings_field('on_page', 'На статических страницах', array(
270
+ $this,
271
+ 'uptolike_on_page_callback'), $this->settings_page_name, 'setting_section_id');
272
 
273
+ add_settings_field('on_post', 'На страницах записей', array(
274
+ $this,
275
+ 'uptolike_on_post_callback'), $this->settings_page_name, 'setting_section_id');
276
 
277
+ add_settings_field('on_archive', 'На страницах архивов', array(
278
+ $this,
279
+ 'uptolike_on_archive_callback'), $this->settings_page_name, 'setting_section_id');
280
 
281
+ add_settings_field('on_special_pages', 'На спец. страницах <p class="utl_quest"><img class="utl_quest" src="' . plugin_dir_url(__FILE__) . '/images/quest.png"><span class="utl_quest">Отображается только боковая панель на страницах, созданных плагинами (WooCommerce, WP-Shop и т.д.)</span></p>', array(
282
+ $this,
283
+ 'uptolike_on_special_pages_callback'), $this->settings_page_name, 'setting_section_id');
284
 
285
+ add_settings_field('widget_position', 'Расположение блока', array(
286
+ $this,
287
+ 'uptolike_widget_position_callback'), $this->settings_page_name, 'setting_section_id');
288
 
289
+ add_settings_field('widget_align', 'Выравнивание блока', array(
290
+ $this,
291
+ 'uptolike_widget_align_callback'), $this->settings_page_name, 'setting_section_id');
292
 
293
+ add_settings_field('widget_mode', 'Режим работы', array(
294
+ $this,
295
+ 'uptolike_widget_mode_callback'), $this->settings_page_name, 'setting_section_id');
296
 
297
+ add_settings_field('utl_language', 'Язык', array(
298
+ $this,
299
+ 'uptolike_language_callback'), $this->settings_page_name, 'setting_section_id');
300
 
301
+ add_settings_field('uptolike_json', 'настройки конструктора', array(
302
+ $this,
303
+ 'uptolike_json_callback'), $this->settings_page_name, 'setting_section_id');
304
  }
305
 
306
  /**
310
  */
311
  public function uptolike_sanitize($input) {
312
  $new_input = array();
313
+ if (isset($input['id_number']))
314
+ $new_input['id_number'] = str_replace(' ', '', $input['id_number']);
315
 
316
+ if (isset($input['widget_code']))
317
+ $new_input['widget_code'] = $input['widget_code'];
318
 
319
+ if (isset($input['uptolike_email']))
320
+ $new_input['uptolike_email'] = $input['uptolike_email'];
321
 
322
+ if (isset($input['before_content']))
323
+ $new_input['before_content'] = $input['before_content'];
324
 
325
  if (isset($input['on_main'])) {
326
  $new_input['on_main'] = 1;
327
+ }
328
+ else $new_input['on_main'] = 0;
329
 
330
  if (isset($input['on_page'])) {
331
  $new_input['on_page'] = 1;
332
+ }
333
+ else $new_input['on_page'] = 0;
334
 
335
  if (isset($input['on_post'])) {
336
  $new_input['on_post'] = 1;
337
+ }
338
+ else $new_input['on_post'] = 0;
339
 
340
  if (isset($input['on_special_pages'])) {
341
  $new_input['on_special_pages'] = 1;
342
+ }
343
+ else $new_input['on_special_pages'] = 0;
344
 
345
  if (isset($input['on_archive'])) {
346
  $new_input['on_archive'] = 1;
347
+ }
348
+ else $new_input['on_archive'] = 0;
349
 
350
+ if (isset($input['email']))
351
+ $new_input['email'] = trim($input['email']);
352
 
353
+ if (isset($input['after_content']))
354
+ $new_input['after_content'] = $input['after_content'];
355
 
356
+ if (isset($input['widget_position']))
357
+ $new_input['widget_position'] = $input['widget_position'];
358
 
359
+ if (isset($input['widget_mode']))
360
+ $new_input['widget_mode'] = $input['widget_mode'];
361
 
362
+ if (isset($input['widget_align']))
363
+ $new_input['widget_align'] = $input['widget_align'];
364
 
365
+ if (isset($input['utl_language']))
366
+ $new_input['utl_language'] = $input['utl_language'];
367
 
368
 
369
+ if (isset($input['uptolike_json']))
370
+ $new_input['uptolike_json'] = $input['uptolike_json'];
371
 
372
  return $new_input;
373
  }
439
  if (isset($this->options['widget_mode'])) {
440
  if ($this->options['widget_mode'] == 'plg') {
441
  $plg_mode = "selected='selected'";
442
+ }
443
+ elseif ($this->options['widget_mode'] == 'code') {
444
  $code_mode = "selected='selected'";
445
+ }
446
+ elseif ($this->options['widget_mode'] == 'both') {
447
  $both_mode = "selected='selected'";
448
  }
449
+ }
450
+ else {
451
  $uptolike_options = get_option('uptolike_options');
452
  $uptolike_options['widget_mode'] = 'plg'; // cryptkey store
453
  update_option('uptolike_options', $uptolike_options);
465
  if (isset($this->options['widget_align'])) {
466
  if ('left' == $this->options['widget_align']) {
467
  $left = "selected='selected'";
468
+ }
469
+ elseif ('right' == $this->options['widget_align']) {
470
  $right = "selected='selected'";
471
+ }
472
+ elseif ('center' == $this->options['widget_align']) {
473
  $center = "selected='selected'";
474
  }
475
+ }
476
+ else {
477
  $uptolike_options = get_option('uptolike_options');
478
  $uptolike_options['widget_align'] = 'left'; // cryptkey store
479
  update_option('uptolike_options', $uptolike_options);
492
  if (isset($this->options['widget_position'])) {
493
  if ($this->options['widget_position'] == 'top') {
494
  $top = "selected='selected'";
495
+ }
496
+ elseif ($this->options['widget_position'] == 'bottom') {
497
  $bottom = "selected='selected'";
498
+ }
499
+ elseif ($this->options['widget_position'] == 'both') {
500
  if (json_decode($this->options['uptolike_json'])->orientation < 2) {
501
  $both = "selected='selected'";
502
+ }
503
+ else {
504
  $both = '';
505
  $bottom = "selected='selected'";
506
  $uptolike_options = get_option('uptolike_options');
507
  $uptolike_options['widget_position'] = 'bottom'; // cryptkey store
508
  update_option('uptolike_options', $uptolike_options);
509
  }
510
+ }
511
+ else {
512
  $bottom = "selected='selected'";
513
  }
514
+ }
515
+ else {
516
  $uptolike_options = get_option('uptolike_options');
517
  $uptolike_options['widget_position'] = 'bottom'; // cryptkey store
518
  update_option('uptolike_options', $uptolike_options);
532
  if (isset($this->options['utl_language'])) {
533
  if ($this->options['utl_language'] == 'ru') {
534
  $ru = "selected='selected'";
535
+ }
536
+ elseif ('en' == $this->options['utl_language']) {
537
  $en = "selected='selected'";
538
+ }
539
+ elseif ('ua' == $this->options['utl_language']) {
540
  $ua = "selected='selected'";
541
+ }
542
+ elseif ('de' == $this->options['utl_language']) {
543
  $de = "selected='selected'";
544
+ }
545
+ elseif ('es' == $this->options['utl_language']) {
546
  $es = "selected='selected'";
547
+ }
548
+ elseif ('it' == $this->options['utl_language']) {
549
  $it = "selected='selected'";
550
+ }
551
+ elseif ('pl' == $this->options['utl_language']) {
552
  $pl = "selected='selected'";
553
+ }
554
+ elseif ('lt' == $this->options['utl_language']) {
555
  $lt = "selected='selected'";
556
+ }
557
+ elseif ('cz' == $this->options['utl_language']) {
558
  $cz = "selected='selected'";
559
+ }
560
+ else {
561
  $ru = "selected='selected'";
562
  }
563
+ }
564
+ else {
565
  $uptolike_options = get_option('uptolike_options');
566
  $uptolike_options['utl_language'] = 'ru'; // cryptkey store
567
  update_option('uptolike_options', $uptolike_options);
583
  function uptolike_get_widget_code($url = '') {
584
  $options = get_option('uptolike_options');
585
  $widget_code = $options['widget_code'];
586
+ $protocol = 'http';
587
+ if (is_ssl()) {
588
+ $protocol .= "s";
589
+ }
590
+ $protocol .= "://";
591
  if ($url == '') {
592
+ $url = $protocol . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
593
  }
594
 
595
  if ($_SERVER["REQUEST_URI"] == '/' && !(json_decode($options['uptolike_json'])->orientation < 2) && !empty(json_decode($options['uptolike_json'])->orientation)) {
625
  case 'bottom':
626
  return $content . uptolike_get_widget_code(get_permalink());
627
  }
628
+ }
629
+ elseif ($options['on_main'] != 1 && (home_url('/') == request_home_url())) {
630
  return $content;
631
+ }
632
+ elseif ($options['on_page'] == 1 && home_url('/') != request_home_url()) {
633
  switch ($options['widget_position']) {
634
  case 'both':
635
  return uptolike_get_widget_code(get_permalink()) . $content . uptolike_get_widget_code(get_permalink());
639
  return $content . uptolike_get_widget_code(get_permalink());
640
  }
641
  }
642
+ }
643
+ elseif (is_page() && $options['on_page'] == 1 && (home_url('/') != request_home_url())) {
644
  switch ($options['widget_position']) {
645
  case 'both':
646
  return uptolike_get_widget_code(get_permalink()) . $content . uptolike_get_widget_code(get_permalink());
649
  case 'bottom':
650
  return $content . uptolike_get_widget_code(get_permalink());
651
  }
652
+ }
653
+ elseif (is_single() && $options['on_post'] == 1 && (home_url('/') != request_home_url())) {
654
  switch ($options['widget_position']) {
655
  case 'both':
656
  return uptolike_get_widget_code(get_permalink()) . $content . uptolike_get_widget_code(get_permalink());
659
  case 'bottom':
660
  return $content . uptolike_get_widget_code(get_permalink());
661
  }
662
+ }
663
+ elseif (is_archive() && $options['on_archive'] == 1 && $options['on_post'] == 1) {
664
  switch ($options['widget_position']) {
665
  case 'both':
666
  return uptolike_get_widget_code(get_permalink()) . $content . uptolike_get_widget_code(get_permalink());
670
  return $content . uptolike_get_widget_code(get_permalink());
671
  }
672
  }
673
+ }
674
+ else { //if vertical panel
675
  if (is_front_page() || is_home()) {
676
  if ($options['on_main'] == 1 && (home_url('/') == request_home_url())) {
677
  add_action('wp_footer', 'uptolike_header');
678
+ }
679
+ elseif ($options['on_page'] == 1 && home_url('/') != request_home_url()) {
680
  add_action('wp_footer', 'uptolike_header');
681
  }
682
+ }
683
+ elseif (is_page()) {
684
  if ($options['on_page'] == 1 && (home_url('/') != request_home_url())) {
685
  add_action('wp_footer', 'uptolike_header');
686
  }
687
+ }
688
+ elseif (is_single()) {
689
  if ($options['on_post'] == 1 && (home_url('/') != request_home_url())) {
690
  add_action('wp_footer', 'uptolike_header');
691
  }
692
+ }
693
+ elseif (is_archive()) {
694
  if ($options['on_archive'] == 1 && $options['on_post'] == 1 && (home_url('/') != request_home_url())) {
695
  add_action('wp_footer', 'uptolike_header');
696
  }
709
  if (is_front_page() || is_home()) {
710
  if ($options['on_main'] == 1 && (home_url('/') == request_home_url())) {
711
  return uptolike_get_widget_code();
712
+ }
713
+ elseif ($options['on_main'] != 1 && (home_url('/') == request_home_url())) {
714
  return;
715
+ }
716
+ elseif ($options['on_page'] == 1 && home_url('/') != request_home_url()) {
717
  return uptolike_get_widget_code();
718
  }
719
+ }
720
+ elseif (is_page() && $options['on_page'] == 1 && (home_url('/') != request_home_url())) {
721
  return uptolike_get_widget_code();
722
+ }
723
+ elseif (is_single() && $options['on_post'] == 1 && (home_url('/') != request_home_url())) {
724
  return uptolike_get_widget_code();
725
+ }
726
+ elseif (is_archive() && $options['on_archive'] == 1 && $options['on_post'] == 1) {
727
  return uptolike_get_widget_code();
728
  }
729
  }
754
  function uptolike_user_reg($email, $partnerId, $projectId) {
755
 
756
  if ($email !== '' && $partnerId !== '' && $projectId !== '') {
757
+ $url = 'https://uptolike.com/api/getCryptKeyWithUserReg.json?' . http_build_query(array(
758
+ 'email' => $email,
759
+ 'partner' => $partnerId,
760
+ 'projectId' => $projectId));
761
 
762
  $jsonAnswer = file_get_contents($url);
763
  if (false !== $jsonAnswer) {
764
  $answer = json_decode($jsonAnswer);
765
  return $answer->cryptKey;
766
+ }
767
+ else return $jsonAnswer;
768
 
769
+ }
770
+ else return 'one of params is empty';
771
  }
772
 
773
  function uptolike_try_reg() {
860
  wp_die(__('Plugin UpToLike has been installed incorrectly.'));
861
  }
862
  if (function_exists('add_plugins_page')) {
863
+ add_plugins_page('UpToLike Settings', 'UpToLike', 'manage_options', basename(__FILE__), array(
864
+ &$uptolike_settings_page,
865
+ 'uptolike_create_admin_page'));
866
  }
867
  }
868
 
872
  if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) {
873
  $result .= 'https://';
874
  $default_port = 443;
875
+ }
876
+ else {
877
  $result .= 'http://';
878
  }
879
  $result .= $_SERVER['SERVER_NAME'];
894
  $in_fixed_block = array(2, 3, 4, 5);
895
  $curr_value = json_decode($options['uptolike_json'])->orientation;
896
  if (in_array($curr_value, $in_content)) {
897
+ }
898
+ elseif (in_array($curr_value, $in_fixed_block)) {
899
  echo uptolike_get_widget_code();
900
  }
901
+ }
902
+ elseif ((home_url('/') != request_home_url()) && ($options['on_special_pages'] == 1 || $options['on_page'] == 1)) {
903
  $in_content = array(0, 1);
904
  $in_fixed_block = array(2, 3, 4, 5);
905
  $curr_value = json_decode($options['uptolike_json'])->orientation;
906
  if (in_array($curr_value, $in_content)) {
907
  echo uptolike_get_widget_code();
908
+ }
909
+ elseif (in_array($curr_value, $in_fixed_block)) {
910
  echo uptolike_get_widget_code();
911
  }
912
+ }
913
+ elseif ((home_url('/') != request_home_url()) && ($options['on_post'] == 1)) {
914
  $in_content = array(0, 1);
915
  $in_fixed_block = array(2, 3, 4, 5);
916
  $curr_value = json_decode($options['uptolike_json'])->orientation;
917
  if (in_array($curr_value, $in_content)) {
918
  echo uptolike_get_widget_code();
919
+ }
920
+ elseif (in_array($curr_value, $in_fixed_block)) {
921
  echo uptolike_get_widget_code();
922
  }
923
  }