Uptolike Social Share Buttons - Version 1.2.3

Version Description

  • Bug fix: show on main
Download this release

Release Info

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

Version 1.2.3

api_functions.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ const HOST = 'http://uptolike.com/';
4
+
5
+ /**
6
+ * @param $email
7
+ * @param $partnerId 'cms' for cms modules
8
+ * @param $projectId 'cms'.site name
9
+ * @return bool|string 'if false - somthing wrong, if string - it's cryptkey'
10
+ */
11
+ function userReg($email, $partnerId, $projectId){
12
+
13
+ if ($email !== '' && $partnerId !== '' && $projectId !== '') {
14
+ $url = 'http://uptolike.com/api/getCryptKeyWithUserReg.json?'.http_build_query(array(
15
+ 'email' => $email,
16
+ 'partner' => $partnerId,
17
+ 'projectId' => $projectId));
18
+
19
+ $jsonAnswer = file_get_contents($url);
20
+ if (false !== $jsonAnswer) {
21
+ $answer = json_decode($jsonAnswer);
22
+ return $answer->cryptKey;
23
+ } else return $jsonAnswer;
24
+
25
+ } else return 'one of params is empty';
26
+ }
27
+
28
+ /**
29
+ * @param $partnerId String'cms' for cms modules
30
+ * @param $email String
31
+ * @param $cryptKey String
32
+ */
33
+ function statIframe($partnerId, $mail, $cryptKey) {
34
+ $params = array(
35
+ 'mail' => $mail,
36
+ 'partner' => $partnerId
37
+ );
38
+ $paramsStr = 'mail='.$mail.'&partner='.$partnerId;
39
+ $signature = md5($paramsStr.$cryptKey);
40
+ $params['signature'] = $signature;
41
+ $finalUrl = 'http://uptolike.com/api/statistics.html?'.http_build_query($params);
42
+
43
+ return $finalUrl;
44
+ }
45
+
46
+ /**
47
+ * @param $mail user email
48
+ * @param $partnerId 'cms' for cms sites
49
+ * @param $projectId 'cms'.site_name
50
+ * @param $cryptKey crypt key, received from server
51
+ * @return string
52
+ */
53
+ function constructorIframe($mail, $partnerId, $projectId, $cryptKey) {
54
+
55
+ $params = array ('mail' => $mail,
56
+ 'partner' => $partnerId,
57
+ 'projectId' => $projectId);
58
+
59
+ $paramsStr = 'mail='.$mail.'&partner='.$partnerId.'&projectId='.$projectId.$cryptKey;
60
+ //echo http_build_query($params).$cryptKey;
61
+ $signature = md5($paramsStr);
62
+ $params['signature'] = $signature;
63
+ $finalUrl = 'http://uptolike.com/api/constructor.html?'.http_build_query($params);
64
+
65
+ return $finalUrl;
66
+ }
67
+
68
+
main.js ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Created by root on 02.06.14.
3
+ */
4
+
5
+ var onmessage = function (e) {
6
+ if ('ready' == e.data.action ){
7
+ json = jQuery('input#uptolike_json').val();
8
+ initConstr(json);
9
+ }
10
+ if (('json' in e.data) && ('code' in e.data)) {
11
+ $('input#uptolike_json').val(e.data.json);
12
+ $('#widget_code').val(e.data.code);
13
+ jQuery('#settings_form').submit();
14
+ }
15
+ if (e.data.url.indexOf('constructor.html', 0) != -1) {
16
+ document.getElementById("cons_iframe").style.height = e.data.size + 'px';
17
+ }
18
+ if (e.data.url.indexOf('statistics.html', 0) != -1) {
19
+ document.getElementById("stats_iframe").style.height = e.data.size + 'px';
20
+ }
21
+ };
22
+
23
+ if (typeof window.addEventListener != 'undefined') {
24
+ window.addEventListener('message', onmessage, false);
25
+ } else if (typeof window.attachEvent != 'undefined') {
26
+ window.attachEvent('onmessage', onmessage);
27
+ }
28
+ var getCode = function () {
29
+ var win = document.getElementById("cons_iframe").contentWindow;
30
+ win.postMessage({action: 'getCode'}, "*");
31
+ };
32
+ function initConstr(jsonStr) {
33
+ var win = document.getElementById("cons_iframe").contentWindow;
34
+ if ('' !== jsonStr) {
35
+ win.postMessage({action: 'initialize', json: jsonStr}, "*");
36
+ }
37
+
38
+ }
39
+
40
+
41
+ function regMe(my_mail) {
42
+ str = jQuery.param({ email: my_mail,
43
+ partner: 'cms',
44
+ projectId: 'cms' + document.location.host.replace( new RegExp("^www.","gim"),"").replace(/\-/g, '').replace(/\./g, ''),
45
+ url:document.location.host.replace( new RegExp("^www.","gim"),"")})
46
+ dataURL = "http://uptolike.com/api/getCryptKeyWithUserReg.json";
47
+ jQuery.getJSON(dataURL + "?" + str + "&callback=?", {}, function (result) {
48
+ var jsonString = JSON.stringify(result);
49
+ var result = JSON.parse(jsonString);
50
+ if ('ALREADY_EXISTS' == result.statusCode) {
51
+ alert('Пользователь с таким email уже зарегистрирован, обратитесь в службу поддержки.');
52
+ } else if ('MAIL_SENDED' == result.statusCode) {
53
+ alert('Ключ отправлен вам на email. Теперь необходимо ввести его в поле ниже.');
54
+ $('.reg_block').toggle('fast');
55
+ $('.reg_btn').toggle('fast');
56
+ $('.enter_btn').toggle('fast');
57
+ $('.enter_block').toggle('fast');
58
+
59
+ } else if ('ILLEGAL_ARGUMENTS' == result.statusCode) {
60
+ alert('Email указан неверно.')
61
+ }
62
+ });
63
+ }
64
+
65
+ function hashChange(){
66
+ var hsh = document.location.hash
67
+ if (('#reg' == hsh) || ('#enter' == hsh)) {
68
+
69
+ $('.nav-tab-wrapper a').removeClass('nav-tab-active');
70
+ $('a.nav-tab#stat').addClass('nav-tab-active');
71
+ $('.wrapper-tab').removeClass('active');
72
+ $('#con_stat').addClass('active');
73
+
74
+ if ('#reg' == hsh) {
75
+ $('.reg_btn').show();
76
+ $('.reg_block').show();
77
+ $('.enter_btn').hide();
78
+ $('.enter_block').hide();
79
+ }
80
+ if ('#enter' == hsh) {
81
+ $('.reg_btn').hide();
82
+ $('.reg_block').hide();
83
+ $('.enter_btn').show();
84
+ $('.enter_block').show();
85
+ }
86
+ }
87
+ }
88
+
89
+ window.onhashchange = function() {
90
+ hashChange();
91
+ }
92
+
93
+ jQuery(document).ready(function () {
94
+ $ = jQuery;
95
+
96
+ $('input.id_number').css('width','520px');//TODO dafuq? fixit
97
+ $('.uptolike_email').val($('#uptolike_email').val())//init fields with hidden value (server email)
98
+ $('.enter_block input.id_number').attr('value', $('table input.id_number').val());
99
+
100
+ $('div.enter_block').hide();
101
+ $('div.reg_block').hide();
102
+
103
+ $('.reg_btn').click(function(){
104
+ $('.reg_block').toggle('fast');
105
+ $('.enter_btn').toggle('fast');
106
+ })
107
+
108
+ $('.enter_btn').click(function(){
109
+ $('.enter_block').toggle('fast');
110
+ $('.reg_btn').toggle('fast');
111
+ })
112
+
113
+ $('.reg_block button').click(function(){
114
+ my_email = $('.reg_block .uptolike_email').val();
115
+ regMe(my_email);
116
+ })
117
+
118
+ $('.enter_block button').click(function(){
119
+ my_email = $('.enter_block input.uptolike_email').val();
120
+ my_key = $('.enter_block input.id_number').val();
121
+ $('table input.id_number').attr('value',my_key);
122
+ $('table input#uptolike_email').attr('value',my_email);
123
+ $('#settings_form').submit();
124
+ })
125
+
126
+ //если юзер не зареган
127
+ if ($('.id_number').val() == '') {
128
+ $('#uptolike_email').after('<button type="button" onclick="regMe();">Зарегистрироваться</button>');
129
+ json = $('input#uptolike_json').val();
130
+ initConstr(json);
131
+ }
132
+ $('#widget_code').parent().parent().attr('style', 'display:none');
133
+ $('#uptolike_json').parent().parent().attr('style', 'display:none')
134
+ $('table .id_number').parent().parent().attr('style', 'display:none')
135
+ $('#uptolike_email').parent().parent().attr('style', 'display:none')
136
+
137
+ $('.nav-tab-wrapper a').click(function (e) {
138
+ e.preventDefault();
139
+ var click_id = $(this).attr('id');
140
+ if (click_id != $('.nav-tab-wrapper a.nav-tab-active').attr('id')) {
141
+ $('.nav-tab-wrapper a').removeClass('nav-tab-active');
142
+ $(this).addClass('nav-tab-active');
143
+ $('.wrapper-tab').removeClass('active');
144
+ $('#con_' + click_id).addClass('active');
145
+ }
146
+ });
147
+
148
+ hashChange();
149
+ $.getScript( "http://uptolike.com/api/getsession.json" )
150
+ .done(function( script, textStatus ) {
151
+ $('iframe#cons_iframe').attr('src',$('iframe#cons_iframe').attr('data-src'));
152
+ $('iframe#stats_iframe').attr('src',$('iframe#stats_iframe').attr('data-src'));
153
+ });
154
+
155
+ });
156
+
readme.txt ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Uptolike Share Buttons ===
2
+ Contributors: na1vez
3
+ Tags: +1, UpToLike, AddThis, social buttons, bookmark, bookmarking, like, share, share button, sharing, social bookmarking, social bookmarks, social buttons
4
+ Requires at least: 3.0.1
5
+ Tested up to: 4.0
6
+ Stable tag: 1.2.3
7
+
8
+ Uptolike Share Buttons - social bookmarking widget with sharing statistics.
9
+
10
+ == Description ==
11
+ **What Can You Do With UpToLike 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 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 Share Buttons**
28
+
29
+ * Customization of social buttons:
30
+
31
+ 1. 3 different shapes
32
+ 2. 6 sizes
33
+ 3. Hover effect (increase, clockwise rotation)
34
+ 4. 11 button styles
35
+ 5. Button background
36
+ 6. Text color
37
+ 7. Text size of the counter
38
+
39
+ * Social Media Following
40
+ * Automatic text selection: the system gives you the option to share a highlighted piece of text on a social network
41
+
42
+ * Gathering unique statistics of social media activity
43
+
44
+ **What statistics does UpToLike collect?**
45
+
46
+ * Number of Likes and Shares on site during the selected period
47
+ * Number of users attracted because of Likes and Shares
48
+ * Separation of traffic on social networks
49
+ * Per-page site activity: how many Likes and Shares for each individual page, and how many new visitors came to each page
50
+
51
+
52
+ == Installation ==
53
+ 1. Go to Plugins -> Add New
54
+ 2. Search for Uptolike
55
+ 3. Install the plugin called \\\"Uptolike Share Buttons\\\" and activate it
56
+ 4. Adjust your settings
57
+ 5. Request and fill the secret key field, if you want to receive the statistics
58
+ 6. Enjoy!
59
+
60
+ == Frequently Asked Questions ==
61
+ Answers to Frequently Asked Questions you can find at http://uptolike.ru/faq
62
+
63
+ == Screenshots ==
64
+ 1. Customizing sharing buttons
65
+ 2. Buttons appearance
66
+ 3. Traffic and sharing statistics
67
+
68
+ == Changelog ==
69
+ = 1.2.3 =
70
+ * Bug fix: show on main
71
+
72
+ = 1.2.2 =
73
+ * Enhancement: cut spaces in cryptkey field
74
+ * Enhancement: feedback link
75
+ * Enhancement: access to plugins by top menu item
76
+
77
+ = 1.2.1 =
78
+ * Bug Fix: minor bug fixes
79
+
80
+ = 1.2.0 =
81
+ * Enhancement: user registration.
82
+
83
+ = 1.0.0 =
84
+ * Initial release
reg_sample.html ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title></title>
5
+ </head>
6
+ <body>
7
+
8
+ </body>
9
+ </html>
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
test.html ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>
trunk/api_functions.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ const HOST = 'http://uptolike.com/';
4
+
5
+ /**
6
+ * @param $email
7
+ * @param $partnerId 'cms' for cms modules
8
+ * @param $projectId 'cms'.site name
9
+ * @return bool|string 'if false - somthing wrong, if string - it's cryptkey'
10
+ */
11
+ function userReg($email, $partnerId, $projectId){
12
+
13
+ if ($email !== '' && $partnerId !== '' && $projectId !== '') {
14
+ $url = 'http://uptolike.com/api/getCryptKeyWithUserReg.json?'.http_build_query(array(
15
+ 'email' => $email,
16
+ 'partner' => $partnerId,
17
+ 'projectId' => $projectId));
18
+
19
+ $jsonAnswer = file_get_contents($url);
20
+ if (false !== $jsonAnswer) {
21
+ $answer = json_decode($jsonAnswer);
22
+ return $answer->cryptKey;
23
+ } else return $jsonAnswer;
24
+
25
+ } else return 'one of params is empty';
26
+ }
27
+
28
+ /**
29
+ * @param $partnerId String'cms' for cms modules
30
+ * @param $email String
31
+ * @param $cryptKey String
32
+ */
33
+ function statIframe($partnerId, $mail, $cryptKey) {
34
+ $params = array(
35
+ 'mail' => $mail,
36
+ 'partner' => $partnerId
37
+ );
38
+ $paramsStr = 'mail='.$mail.'&partner='.$partnerId;
39
+ $signature = md5($paramsStr.$cryptKey);
40
+ $params['signature'] = $signature;
41
+ $finalUrl = 'http://uptolike.com/api/statistics.html?'.http_build_query($params);
42
+
43
+ return $finalUrl;
44
+ }
45
+
46
+ /**
47
+ * @param $mail user email
48
+ * @param $partnerId 'cms' for cms sites
49
+ * @param $projectId 'cms'.site_name
50
+ * @param $cryptKey crypt key, received from server
51
+ * @return string
52
+ */
53
+ function constructorIframe($mail, $partnerId, $projectId, $cryptKey) {
54
+
55
+ $params = array ('mail' => $mail,
56
+ 'partner' => $partnerId,
57
+ 'projectId' => $projectId);
58
+
59
+ $paramsStr = 'mail='.$mail.'&partner='.$partnerId.'&projectId='.$projectId.$cryptKey;
60
+ //echo http_build_query($params).$cryptKey;
61
+ $signature = md5($paramsStr);
62
+ $params['signature'] = $signature;
63
+ $finalUrl = 'http://uptolike.com/api/constructor.html?'.http_build_query($params);
64
+
65
+ return $finalUrl;
66
+ }
67
+
68
+
trunk/main.js ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Created by root on 02.06.14.
3
+ */
4
+
5
+ var onmessage = function (e) {
6
+ if ('ready' == e.data.action ){
7
+ json = jQuery('input#uptolike_json').val();
8
+ initConstr(json);
9
+ }
10
+ if (('json' in e.data) && ('code' in e.data)) {
11
+ $('input#uptolike_json').val(e.data.json);
12
+ $('#widget_code').val(e.data.code);
13
+ jQuery('#settings_form').submit();
14
+ }
15
+ if (e.data.url.indexOf('constructor.html', 0) != -1) {
16
+ document.getElementById("cons_iframe").style.height = e.data.size + 'px';
17
+ }
18
+ if (e.data.url.indexOf('statistics.html', 0) != -1) {
19
+ document.getElementById("stats_iframe").style.height = e.data.size + 'px';
20
+ }
21
+ };
22
+
23
+ if (typeof window.addEventListener != 'undefined') {
24
+ window.addEventListener('message', onmessage, false);
25
+ } else if (typeof window.attachEvent != 'undefined') {
26
+ window.attachEvent('onmessage', onmessage);
27
+ }
28
+ var getCode = function () {
29
+ var win = document.getElementById("cons_iframe").contentWindow;
30
+ win.postMessage({action: 'getCode'}, "*");
31
+ };
32
+ function initConstr(jsonStr) {
33
+ var win = document.getElementById("cons_iframe").contentWindow;
34
+ if ('' !== jsonStr) {
35
+ win.postMessage({action: 'initialize', json: jsonStr}, "*");
36
+ }
37
+
38
+ }
39
+
40
+
41
+ function regMe(my_mail) {
42
+ str = jQuery.param({ email: my_mail,
43
+ partner: 'cms',
44
+ projectId: 'cms' + document.location.host.replace( new RegExp("^www.","gim"),"").replace(/\-/g, '').replace(/\./g, ''),
45
+ url:document.location.host.replace( new RegExp("^www.","gim"),"")})
46
+ dataURL = "http://uptolike.com/api/getCryptKeyWithUserReg.json";
47
+ jQuery.getJSON(dataURL + "?" + str + "&callback=?", {}, function (result) {
48
+ var jsonString = JSON.stringify(result);
49
+ var result = JSON.parse(jsonString);
50
+ if ('ALREADY_EXISTS' == result.statusCode) {
51
+ alert('Пользователь с таким email уже зарегистрирован, обратитесь в службу поддержки.');
52
+ } else if ('MAIL_SENDED' == result.statusCode) {
53
+ alert('Ключ отправлен вам на email. Теперь необходимо ввести его в поле ниже.');
54
+ $('.reg_block').toggle('fast');
55
+ $('.reg_btn').toggle('fast');
56
+ $('.enter_btn').toggle('fast');
57
+ $('.enter_block').toggle('fast');
58
+
59
+ } else if ('ILLEGAL_ARGUMENTS' == result.statusCode) {
60
+ alert('Email указан неверно.')
61
+ }
62
+ });
63
+ }
64
+
65
+ function hashChange(){
66
+ var hsh = document.location.hash
67
+ if (('#reg' == hsh) || ('#enter' == hsh)) {
68
+
69
+ $('.nav-tab-wrapper a').removeClass('nav-tab-active');
70
+ $('a.nav-tab#stat').addClass('nav-tab-active');
71
+ $('.wrapper-tab').removeClass('active');
72
+ $('#con_stat').addClass('active');
73
+
74
+ if ('#reg' == hsh) {
75
+ $('.reg_btn').show();
76
+ $('.reg_block').show();
77
+ $('.enter_btn').hide();
78
+ $('.enter_block').hide();
79
+ }
80
+ if ('#enter' == hsh) {
81
+ $('.reg_btn').hide();
82
+ $('.reg_block').hide();
83
+ $('.enter_btn').show();
84
+ $('.enter_block').show();
85
+ }
86
+ }
87
+ }
88
+
89
+ window.onhashchange = function() {
90
+ hashChange();
91
+ }
92
+
93
+ jQuery(document).ready(function () {
94
+ $ = jQuery;
95
+
96
+ $('input.id_number').css('width','520px');//TODO dafuq? fixit
97
+ $('.uptolike_email').val($('#uptolike_email').val())//init fields with hidden value (server email)
98
+ $('.enter_block input.id_number').attr('value', $('table input.id_number').val());
99
+
100
+ $('div.enter_block').hide();
101
+ $('div.reg_block').hide();
102
+
103
+ $('.reg_btn').click(function(){
104
+ $('.reg_block').toggle('fast');
105
+ $('.enter_btn').toggle('fast');
106
+ })
107
+
108
+ $('.enter_btn').click(function(){
109
+ $('.enter_block').toggle('fast');
110
+ $('.reg_btn').toggle('fast');
111
+ })
112
+
113
+ $('.reg_block button').click(function(){
114
+ my_email = $('.reg_block .uptolike_email').val();
115
+ regMe(my_email);
116
+ })
117
+
118
+ $('.enter_block button').click(function(){
119
+ my_email = $('.enter_block input.uptolike_email').val();
120
+ my_key = $('.enter_block input.id_number').val();
121
+ $('table input.id_number').attr('value',my_key);
122
+ $('table input#uptolike_email').attr('value',my_email);
123
+ $('#settings_form').submit();
124
+ })
125
+
126
+ //если юзер не зареган
127
+ if ($('.id_number').val() == '') {
128
+ $('#uptolike_email').after('<button type="button" onclick="regMe();">Зарегистрироваться</button>');
129
+ json = $('input#uptolike_json').val();
130
+ initConstr(json);
131
+ }
132
+ $('#widget_code').parent().parent().attr('style', 'display:none');
133
+ $('#uptolike_json').parent().parent().attr('style', 'display:none')
134
+ $('table .id_number').parent().parent().attr('style', 'display:none')
135
+ $('#uptolike_email').parent().parent().attr('style', 'display:none')
136
+
137
+ $('.nav-tab-wrapper a').click(function (e) {
138
+ e.preventDefault();
139
+ var click_id = $(this).attr('id');
140
+ if (click_id != $('.nav-tab-wrapper a.nav-tab-active').attr('id')) {
141
+ $('.nav-tab-wrapper a').removeClass('nav-tab-active');
142
+ $(this).addClass('nav-tab-active');
143
+ $('.wrapper-tab').removeClass('active');
144
+ $('#con_' + click_id).addClass('active');
145
+ }
146
+ });
147
+
148
+ hashChange();
149
+ $.getScript( "http://uptolike.com/api/getsession.json" )
150
+ .done(function( script, textStatus ) {
151
+ $('iframe#cons_iframe').attr('src',$('iframe#cons_iframe').attr('data-src'));
152
+ $('iframe#stats_iframe').attr('src',$('iframe#stats_iframe').attr('data-src'));
153
+ });
154
+
155
+ });
156
+
trunk/readme.txt ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Uptolike Share Buttons ===
2
+ Contributors: na1vez
3
+ Tags: +1, UpToLike, AddThis, social buttons, bookmark, bookmarking, like, share, share button, sharing, social bookmarking, social bookmarks, social buttons
4
+ Requires at least: 3.0.1
5
+ Tested up to: 4.0
6
+ Stable tag: 1.2.3
7
+
8
+ Uptolike Share Buttons - social bookmarking widget with sharing statistics.
9
+
10
+ == Description ==
11
+ **What Can You Do With UpToLike 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 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 Share Buttons**
28
+
29
+ * Customization of social buttons:
30
+
31
+ 1. 3 different shapes
32
+ 2. 6 sizes
33
+ 3. Hover effect (increase, clockwise rotation)
34
+ 4. 11 button styles
35
+ 5. Button background
36
+ 6. Text color
37
+ 7. Text size of the counter
38
+
39
+ * Social Media Following
40
+ * Automatic text selection: the system gives you the option to share a highlighted piece of text on a social network
41
+
42
+ * Gathering unique statistics of social media activity
43
+
44
+ **What statistics does UpToLike collect?**
45
+
46
+ * Number of Likes and Shares on site during the selected period
47
+ * Number of users attracted because of Likes and Shares
48
+ * Separation of traffic on social networks
49
+ * Per-page site activity: how many Likes and Shares for each individual page, and how many new visitors came to each page
50
+
51
+
52
+ == Installation ==
53
+ 1. Go to Plugins -> Add New
54
+ 2. Search for Uptolike
55
+ 3. Install the plugin called \\\"Uptolike Share Buttons\\\" and activate it
56
+ 4. Adjust your settings
57
+ 5. Request and fill the secret key field, if you want to receive the statistics
58
+ 6. Enjoy!
59
+
60
+ == Frequently Asked Questions ==
61
+ Answers to Frequently Asked Questions you can find at http://uptolike.ru/faq
62
+
63
+ == Screenshots ==
64
+ 1. Customizing sharing buttons
65
+ 2. Buttons appearance
66
+ 3. Traffic and sharing statistics
67
+
68
+ == Changelog ==
69
+ = 1.2.3 =
70
+ * Bug fix: show on main
71
+
72
+ = 1.2.2 =
73
+ * Enhancement: cut spaces in cryptkey field
74
+ * Enhancement: feedback link
75
+ * Enhancement: access to plugins by top menu item
76
+
77
+ = 1.2.1 =
78
+ * Bug Fix: minor bug fixes
79
+
80
+ = 1.2.0 =
81
+ * Enhancement: user registration.
82
+
83
+ = 1.0.0 =
84
+ * Initial release
trunk/reg_sample.html ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title></title>
5
+ </head>
6
+ <body>
7
+
8
+ </body>
9
+ </html>
trunk/screenshot-1.png ADDED
Binary file
trunk/screenshot-2.png ADDED
Binary file
trunk/screenshot-3.png ADDED
Binary file
trunk/test.html ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>
trunk/uptolike_share_widget.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?
2
+ /*
3
+ Plugin Name: UpToLike Share Buttons
4
+ Plugin URI: http://uptolike.ru/
5
+ Description: Uptolike Share Buttons - social bookmarking widget with sharing statistics.
6
+ Version: 1.2.3
7
+ Author URI: http://uptolike.ru/
8
+ */
9
+
10
+
11
+ // Creating the widget
12
+
13
+ include 'widget_options.php';
trunk/uptolike_style.css ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ .id_number {
4
+ width: 520px;
5
+ }
6
+
7
+ h2.placeholder {
8
+ font-size: 1px;
9
+ padding: 1px;
10
+ margin: 0px;
11
+ height: 2px;
12
+ }
13
+
14
+ div.wrapper-tab {
15
+ display: none;
16
+ }
17
+
18
+ div.wrapper-tab.active {
19
+ display: block;
20
+ width: 100%;
21
+ }
22
+
trunk/usb-admin.php ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function constructorIframe($projectId, $partnerId, $mail, $cryptKey)
3
+ {
4
+
5
+ $params = array('mail' => $mail,
6
+ 'partner' => $partnerId,
7
+ 'projectId' => $projectId);
8
+
9
+ $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId . '&projectId=' . $projectId . $cryptKey;
10
+ $signature = md5($paramsStr);
11
+ $params['signature'] = $signature;
12
+ if ('' !== $cryptKey) {
13
+ $finalUrl = 'http://uptolike.com/api/constructor.html?' . http_build_query($params);
14
+ } else $finalUrl = 'http://uptolike.com/api/constructor.html';
15
+
16
+
17
+ return $finalUrl;
18
+ }
19
+
20
+ function statIframe($projectId, $partnerId, $mail, $cryptKey)
21
+ {
22
+ $params = array(
23
+ 'mail' => $mail,
24
+ 'partner' => $partnerId,
25
+ 'projectId' => $projectId,
26
+
27
+ );
28
+ $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId . '&projectId=' . $projectId;
29
+ $signature = md5($paramsStr . $cryptKey);
30
+ $params['signature'] = $signature;
31
+ $finalUrl = 'http://uptolike.com/api/statistics.html?' . http_build_query($params);
32
+
33
+ return $finalUrl;
34
+ }
35
+
36
+ function usb_admin_page()
37
+ {
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_settings('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
+ /* $this->options = get_option('my_option_name');
53
+
54
+ if ((isset($this->options['uptolike_email'])) && ('' !== $this->options['uptolike_email'])) {
55
+ $email = $this->options['uptolike_email'];
56
+ } else $email = get_settings('admin_email');
57
+ $partnerId = 'cms';
58
+ $projectId = 'cms' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);l
59
+ $projectId = str_replace('.','',$projectId);
60
+ $projectId = str_replace('-','',$projectId);
61
+ $options = get_option('my_option_name');
62
+ if (is_array($options) && array_key_exists('id_number', $options)) {
63
+ $cryptKey = $options['id_number'];
64
+ } else $cryptKey = '';
65
+ */
66
+ ?>
67
+ <script type="text/javascript">
68
+ <? include('main.js'); ?>
69
+ </script>
70
+ <style type="text/css">
71
+ h2.placeholder {
72
+ font-size: 1px;
73
+ padding: 1px;
74
+ margin: 0px;
75
+ height: 2px;
76
+ }
77
+
78
+ div.wrapper-tab {
79
+ display: none;
80
+ }
81
+
82
+ div.wrapper-tab.active {
83
+ display: block;
84
+ width: 100%;
85
+ }
86
+
87
+ input#id_number {
88
+ width: 520px;
89
+ }
90
+ </style>
91
+ <div class="wrap">
92
+ <h2 class="placeholder">&nbsp;</h2>
93
+
94
+ <div id="wrapper">
95
+ <form id="settings_form" method="post" action="options.php">
96
+ <H1> UpToLike виджет</H1>
97
+
98
+ <h2 class="nav-tab-wrapper">
99
+ <a class="nav-tab nav-tab-active" href="#" id="construct">
100
+ Конструктор
101
+ </a>
102
+ <a class="nav-tab" href="#" id="stat">
103
+ Статистика
104
+ </a>
105
+
106
+ <a class="nav-tab" href="#" id="settings">
107
+ Настройки
108
+ </a>
109
+ </h2>
110
+
111
+ <div class="wrapper-tab active" id="con_construct">
112
+ <iframe id='cons_iframe' style='height: 445px;width: 100%;'
113
+ data-src="<?php echo constructorIframe($projectId, $partnerId, $email, $cryptKey); ?>"></iframe>
114
+ <br>
115
+ <a onclick="getCode();" href="#">
116
+ <button type="reset">Сохранить изменения</button>
117
+ </a>
118
+ </div>
119
+ <div class="wrapper-tab" id="con_stat">
120
+ <? if (('' == $partnerId) OR ('' == $email) OR ('' == $cryptKey)) {
121
+
122
+ ?>
123
+ <h2>Статистика</h2>
124
+ <p>Для просмотра статистики необходимо ввести ваш секретный ключ </p>
125
+ <? } else { ?>
126
+ <!-- <?php print_r(array($partnerId, $email, $cryptKey)); ?> -->
127
+ <iframe style="width: 100%;height: 380px;" id="stats_iframe"
128
+ data-src="<?php echo statIframe($projectId, $partnerId, $email, $cryptKey); ?>">
129
+ </iframe> <?
130
+ } ?>
131
+ <button class="reg_btn" type="button">Запросить секретный ключ</button>
132
+ <br/>
133
+
134
+ <div class="reg_block">
135
+ <label>Email<input type="text" class="uptolike_email"></label><br/>
136
+ <button type="button" class="button-primary">Отправить ключ на email</button>
137
+ <br/>
138
+ </div>
139
+ <button class="enter_btn" type="button">Авторизация</button>
140
+ <br/>
141
+
142
+ <div class="enter_block">
143
+ <label>Email<input type="text" class="uptolike_email"></label><br/>
144
+ <label>Ключ<input type="text" class="id_number"></label><br/>
145
+ <button type="button" class="button-primary">Сохранить</button>
146
+ <br/>
147
+ </div>
148
+ </div>
149
+
150
+ <div class="wrapper-tab " id="con_settings">
151
+ <input type="hidden" name="option_page" value="my_option_group"><input type="hidden" name="action"
152
+ value="update"><input
153
+ type="hidden" id="_wpnonce" name="_wpnonce" value="cac4f73a65"><input type="hidden"
154
+ name="_wp_http_referer"
155
+ value="/wp-admin/options-general.php?page=uptolike_settings">
156
+
157
+ <h3>Настройки виджета</h3>
158
+ <table class="form-table">
159
+ <tbody>
160
+ <tr style="display:none">
161
+ <th scope="row">код виджета</th>
162
+ <td><textarea id="widget_code" name="my_option_name[widget_code]"></textarea></td>
163
+ </tr>
164
+ <tr style="display:none">
165
+ <th scope="row">Ключ(CryptKey)</th>
166
+ <td><input type="text" class="id_number" name="my_option_name[id_number]" value=""
167
+ style="width: 520px;"></td>
168
+ </tr>
169
+ <tr style="display:none">
170
+ <th scope="row">email для регистрации</th>
171
+ <td><input type="text" id="uptolike_email" name="my_option_name[uptolike_email]"
172
+ value="pk1z@ya3.ru">
173
+ <button type="button" onclick="regMe();">Зарегистрироваться</button>
174
+ </td>
175
+ </tr>
176
+ <tr>
177
+ <th scope="row">Располагать блок на главной странице</th>
178
+ <td><input type="checkbox" id="on_main" name="my_option_name[on_main]" checked="checked">
179
+ </td>
180
+ </tr>
181
+ <tr>
182
+ <th scope="row">Расположение виджета</th>
183
+ <td><select id="widget_position" name="my_option_name[widget_position]">
184
+ <option value="top">Только сверху</option>
185
+ <option selected="selected" value="bottom">Только снизу</option>
186
+ <option value="both">Сверху и снизу</option>
187
+ </select></td>
188
+ </tr>
189
+ <tr>
190
+ <th scope="row">Обратная связь</th>
191
+ <td><a href="mailto:support@uptolike.com" target="_top"> support@uptolike.com</a></td>
192
+ </tr>
193
+ <tr style="display:none">
194
+ <th scope="row">настройки конструктора</th>
195
+ <td><input type="hidden" id="uptolike_json" name="my_option_name[uptolike_json]" value="">
196
+ </td>
197
+ </tr>
198
+ </tbody>
199
+ </table>
200
+ <input type="submit" name="submit_btn" value="Cохранить изменения">
201
+ </div>
202
+
203
+
204
+ </form>
205
+ </div>
206
+ </div>
207
+ <?php
208
+ }
209
+
210
+ usb_admin_page();
trunk/widget_options.php ADDED
@@ -0,0 +1,648 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class MySettingsPage
5
+ {
6
+
7
+ private $options;
8
+ private $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
+ }
14
+
15
+
16
+ public function add_plugin_page()
17
+ {
18
+ add_options_page(
19
+ 'Settings Admin',
20
+ 'UpToLike',
21
+ 'manage_options',
22
+ $this->settings_page_name, //'my-setting-admin',
23
+ array($this, 'create_admin_page')
24
+ );
25
+ }
26
+
27
+ /** creates url of iframe with statistics page from given params
28
+ *
29
+ * @param $projectId
30
+ * @param $partnerId
31
+ * @param $mail
32
+ * @param $cryptKey
33
+ * @return stringшfr
34
+ */
35
+ public function statIframe($projectId, $partnerId, $mail, $cryptKey)
36
+ {
37
+ $params = array(
38
+ 'mail' => $mail,
39
+ 'partner' => $partnerId,
40
+ 'projectId' => $projectId,
41
+
42
+ );
43
+ $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId. '&projectId=' . $projectId;
44
+ $signature = md5($paramsStr . $cryptKey);
45
+ $params['signature'] = $signature;
46
+ $finalUrl = 'http://uptolike.com/api/statistics.html?' . http_build_query($params);
47
+
48
+ return $finalUrl;
49
+ }
50
+
51
+ /** create url of iframe with constructor from given params
52
+ * @param $projectId
53
+ * @param $partnerId
54
+ * @param $mail
55
+ * @param $cryptKey
56
+ * @return string
57
+ */
58
+ public function constructorIframe($projectId, $partnerId, $mail, $cryptKey)
59
+ {
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 = 'http://uptolike.com/api/constructor.html?' . http_build_query($params);
70
+ } else $finalUrl = 'http://uptolike.com/api/constructor.html';
71
+
72
+
73
+ return $finalUrl;
74
+ }
75
+
76
+
77
+ /** returns tabs html code. May be replace by proper html code
78
+ * @param string $current
79
+ */
80
+ public function ilc_admin_tabs($current = 'construct')
81
+ {
82
+ $tabs = array('construct' => 'Конструктор',
83
+ 'stat' => 'Статистика',
84
+ 'settings' => 'Настройки');
85
+
86
+ echo '<div id="icon-themes" class="icon32"><br></div>';
87
+ echo '<h2 class="nav-tab-wrapper">';
88
+ foreach ($tabs as $tab => $name) {
89
+ $class = ($tab == $current) ? ' nav-tab-active' : '';
90
+ echo "<a class='nav-tab$class' href='#' id=" . $tab . " ref='?page=" . $this->settings_page_name . "&tab=$tab'>$name</a>";
91
+
92
+ }
93
+ echo '</h2>';
94
+ }
95
+
96
+ /** render html page with code configuration settings
97
+ *
98
+ */
99
+ public function create_admin_page()
100
+ {
101
+ $this->options = get_option('my_option_name');
102
+
103
+ if ((isset($this->options['uptolike_email'])) && ('' !== $this->options['uptolike_email'])) {
104
+ $email = $this->options['uptolike_email'];
105
+ } else $email = get_settings('admin_email');
106
+ $partnerId = 'cms';
107
+ $projectId = 'cms' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
108
+ $projectId = str_replace('.','',$projectId);
109
+ $projectId = str_replace('-','',$projectId);
110
+ $options = get_option('my_option_name');
111
+ if (is_array($options) && array_key_exists('id_number', $options)) {
112
+ $cryptKey = $options['id_number'];
113
+ } else $cryptKey = '';
114
+ ?>
115
+ <script type="text/javascript">
116
+ <? include('main.js'); ?>
117
+ </script>
118
+ <style type="text/css">
119
+ h2.placeholder {
120
+ font-size: 1px;
121
+ padding: 1px;
122
+ margin: 0px;
123
+ height: 2px;
124
+ }
125
+
126
+ div.wrapper-tab {
127
+ display: none;
128
+ }
129
+
130
+ div.wrapper-tab.active {
131
+ display: block;
132
+ width: 100%;
133
+ }
134
+
135
+ input#id_number {
136
+ width: 520px;
137
+ }
138
+ </style>
139
+ <div class="wrap">
140
+ <h2 class="placeholder">&nbsp;</h2>
141
+ <div id="wrapper">
142
+ <form id="settings_form" method="post" action="options.php">
143
+ <H1> UpToLike виджет</H1>
144
+ <h2 class="nav-tab-wrapper">
145
+ <a class="nav-tab nav-tab-active" href="#" id="construct">
146
+ Конструктор
147
+ </a>
148
+ <a class="nav-tab" href="#" id="stat">
149
+ Статистика
150
+ </a>
151
+
152
+ <a class="nav-tab" href="#" id="settings">
153
+ Настройки
154
+ </a>
155
+ </h2>
156
+ <div class="wrapper-tab active" id="con_construct">
157
+ <iframe id='cons_iframe' style='height: 445px;width: 100%;' data-src="<?php echo $this->constructorIframe($projectId, $partnerId, $email, $cryptKey); ?>"></iframe>
158
+ <br>
159
+ <a onclick="getCode();" href="#">
160
+ <button type="reset">Сохранить изменения</button>
161
+ </a>
162
+ </div>
163
+ <div class="wrapper-tab" id="con_stat">
164
+ <? if (('' == $partnerId) OR ('' == $email) OR ('' == $cryptKey)) {
165
+
166
+ ?>
167
+ <h2>Статистика</h2>
168
+ <p>Для просмотра статистики необходимо ввести ваш секретный ключ </p>
169
+ <? } else { ?>
170
+ <!-- <?php print_r(array($partnerId,$email, $cryptKey)); ?> -->
171
+ <iframe style="width: 100%;height: 380px;" id="stats_iframe" data-src="<?php echo $this->statIframe($projectId, $partnerId, $email, $cryptKey); ?>">
172
+ </iframe> <?
173
+ } ?>
174
+ <button class="reg_btn" type="button">Запросить секретный ключ</button><br/>
175
+ <div class="reg_block">
176
+ <label>Email<input type="text" class="uptolike_email"></label><br/>
177
+ <button type="button" class="button-primary">Отправить ключ на email</button><br/>
178
+ </div>
179
+ <button class="enter_btn" type="button">Авторизация</button><br/>
180
+ <div class="enter_block" >
181
+ <label>Email<input type="text" class="uptolike_email"></label><br/>
182
+ <label>Ключ<input type="text" class="id_number"></label><br/>
183
+ <button type="button" class="button-primary">Сохранить</button><br/>
184
+ </div>
185
+ </div>
186
+ <div class="wrapper-tab" id="con_settings">
187
+ <?php
188
+ settings_fields('my_option_group');
189
+ do_settings_sections($this->settings_page_name);
190
+ ?>
191
+ <input type="submit" name="submit_btn" value="Cохранить изменения">
192
+ </div>
193
+
194
+ </form>
195
+ </div>
196
+ </div>
197
+ <?php
198
+ }
199
+
200
+ public function page_init()
201
+ {
202
+ register_setting(
203
+ 'my_option_group', // Option group
204
+ 'my_option_name', // Option name
205
+ array($this, 'sanitize') // Sanitize
206
+ );
207
+
208
+ add_settings_section(
209
+ 'setting_section_id', // ID
210
+ 'Настройки виджета', // Title
211
+ array($this, 'print_section_info'), // Callback
212
+ $this->settings_page_name//'my-setting-admin' // Page
213
+ );
214
+
215
+ add_settings_field(
216
+ 'widget_code', // ID
217
+ 'код виджета', // Title
218
+ array($this, 'widget_code_callback'), // Callback
219
+ $this->settings_page_name, //'my-setting-admin', // Page
220
+ 'setting_section_id' // Section
221
+ );
222
+
223
+ add_settings_field(
224
+ 'data_pid', // ID
225
+ 'Ключ(CryptKey)', // Title
226
+ array($this, 'id_number_callback'), // Callback
227
+ $this->settings_page_name, //'my-setting-admin', // Page
228
+ 'setting_section_id' // Section
229
+ );
230
+
231
+ add_settings_field(
232
+ 'email', //ID
233
+ 'email для регистрации',
234
+ array($this, 'uptolike_email_callback'),
235
+ $this->settings_page_name, //'my-setting-admin',
236
+ 'setting_section_id'
237
+ );
238
+
239
+ add_settings_field(
240
+ 'on_main', //ID
241
+ 'Располагать блок на главной странице',
242
+ array($this, 'uptolike_on_main_callback'),
243
+ $this->settings_page_name, //'my-setting-admin',
244
+ 'setting_section_id'
245
+ );
246
+
247
+ add_settings_field(
248
+ 'widget_position', //ID
249
+ 'Расположение виджета',
250
+ array($this, 'uptolike_widget_position_callback'),
251
+ $this->settings_page_name, //'my-setting-admin',
252
+ 'setting_section_id'
253
+ );
254
+
255
+ add_settings_field(
256
+ 'feedback', //ID
257
+ 'Обратная связь',
258
+ array($this, 'uptolike_feedback_callback'),
259
+ $this->settings_page_name, //'my-setting-admin',
260
+ 'setting_section_id'
261
+ );
262
+
263
+
264
+ add_settings_field(
265
+ 'uptolike_json', //ID
266
+ 'настройки конструктора',
267
+ array($this, 'uptolike_json_callback'),
268
+ $this->settings_page_name, //'my-setting-admin',
269
+ 'setting_section_id'
270
+ );
271
+ }
272
+
273
+ /**
274
+ * Sanitize each setting field as needed
275
+ *
276
+ * @param array $input Contains all settings fields as array keys
277
+ */
278
+ public function sanitize($input)
279
+ {
280
+ $new_input = array();
281
+ if (isset($input['id_number']))
282
+ $new_input['id_number'] = str_replace(' ','',$input['id_number']);
283
+
284
+ if (isset($input['widget_code']))
285
+ $new_input['widget_code'] = $input['widget_code'];
286
+
287
+ if (isset($input['uptolike_email']))
288
+ $new_input['uptolike_email'] = $input['uptolike_email'];
289
+
290
+ if (isset($input['before_content']))
291
+ $new_input['before_content'] = $input['before_content'];
292
+
293
+ if (isset($input['on_main'])) {
294
+ $new_input['on_main'] = 1;
295
+ } else $new_input['on_main'] = 0;
296
+
297
+ if (isset($input['email']))
298
+ $new_input['email'] = $input['email'];
299
+
300
+ if (isset($input['after_content']))
301
+ $new_input['after_content'] = $input['after_content'];
302
+
303
+ if (isset($input['widget_position']))
304
+ $new_input['widget_position'] = $input['widget_position'];
305
+
306
+ if (isset($input['uptolike_json']))
307
+ $new_input['uptolike_json'] = $input['uptolike_json'];
308
+
309
+ return $new_input;
310
+ }
311
+
312
+
313
+ public function print_section_info()
314
+ {
315
+ //print 'Enter your settings below:';
316
+ }
317
+
318
+ public function widget_code_callback()
319
+ {
320
+ printf(
321
+ '<textarea id="widget_code" name="my_option_name[widget_code]" >%s</textarea>',
322
+ isset($this->options['widget_code']) ? esc_attr($this->options['widget_code']) : ''
323
+ );
324
+ }
325
+
326
+ /** 12536473050877
327
+ * Get the settings option array and print one of its values
328
+ */
329
+ public function id_number_callback()
330
+ {
331
+ printf(
332
+ '<input type="text" class="id_number" name="my_option_name[id_number]" value="%s" />',
333
+ isset($this->options['id_number']) ? esc_attr($this->options['id_number']) : ''
334
+ );
335
+ }
336
+
337
+ public function uptolike_email_callback()
338
+ {
339
+ printf(
340
+ '<input type="text" id="uptolike_email" name="my_option_name[uptolike_email]" value="%s" />',
341
+ isset($this->options['uptolike_email']) ? esc_attr($this->options['uptolike_email']) : get_settings('admin_email')
342
+ );
343
+ }
344
+
345
+ public function uptolike_json_callback()
346
+ {
347
+ printf(
348
+ '<input type="hidden" id="uptolike_json" name="my_option_name[uptolike_json]" value="%s" />',
349
+ isset($this->options['uptolike_json']) ? esc_attr($this->options['uptolike_json']) : ''
350
+ );
351
+ }
352
+
353
+ public function uptolike_partner_id_callback()
354
+ {
355
+ printf(
356
+ '<input type="text" id="uptolike_partner" name="my_option_name[uptolike_partner]" value="%s" />',
357
+ isset($this->options['uptolike_partner']) ? esc_attr($this->options['uptolike_partner']) : ''
358
+ );
359
+ }
360
+
361
+ public function uptolike_feedback_callback()
362
+ {
363
+ echo '<a href="mailto:support@uptolike.com" target="_top"> support@uptolike.com</a>';
364
+ }
365
+
366
+ public function uptolike_project_callback()
367
+ {
368
+ printf(
369
+ '<input type="text" id="uptolike_project" name="my_option_name[uptolike_project]" value="%s" />',
370
+ isset($this->options['uptolike_project']) ? esc_attr($this->options['uptolike_project']) : ''
371
+ );
372
+ }
373
+
374
+ public function uptolike_on_main_callback()
375
+ {
376
+ echo '<input type="checkbox" id="on_main" name="my_option_name[on_main]"';
377
+ echo ($this->options['on_main'] == '1' ? 'checked="checked"' : ''); echo ' />';
378
+
379
+ }
380
+
381
+
382
+ public function uptolike_widget_position_callback()
383
+ {
384
+ $top = $bottom = $both = $default = '';
385
+
386
+ if (isset($this->options['widget_position'])) {
387
+ if ('top' == $this->options['widget_position']) {
388
+ $top = "selected='selected'";
389
+ } elseif ('bottom' == $this->options['widget_position']) {
390
+ $bottom = "selected='selected'";
391
+ } elseif ('both' == $this->options['widget_position']) {
392
+ $both = "selected='selected'";
393
+ } else {
394
+ $bottom = "selected='selected'";
395
+ }
396
+ } else {
397
+ $my_options = get_option('my_option_name');
398
+ $my_options['widget_position'] = 'bottom'; // cryptkey store
399
+ update_option('my_option_name', $my_options);
400
+ }
401
+ $default = "selected='selected'";
402
+ echo "<select id='widget_position' name='my_option_name[widget_position]'>
403
+ <option {$top} value='top'>Только сверху</option>
404
+ <option {$bottom} value='bottom'>Только снизу</option>
405
+ <option {$both} value='both'>Сверху и снизу</option>
406
+ </select>";
407
+
408
+ }
409
+
410
+ }
411
+
412
+
413
+ function add_widget($content)
414
+ {
415
+ //print_r($options = get_option('my_option_name'));
416
+ //return $content;
417
+
418
+ $options = get_option('my_option_name');
419
+ if (is_array($options) && array_key_exists('widget_code', $options)) {
420
+ $widget_code = $options['widget_code'];
421
+ $url = get_permalink();
422
+
423
+ //fixing bad data-pid
424
+ $domain = preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
425
+ $data_pid = 'cms' . str_replace('.', '', $domain);
426
+
427
+ $widget_code = str_replace('data-pid="-1"','data-pid="' . $data_pid . '"',$widget_code);
428
+ $widget_code = str_replace('data-pid=""','data-pid="' . $data_pid . '"',$widget_code);
429
+ $widget_code = str_replace('div data', 'div data-url="' . $url . '" data', $widget_code);
430
+ $widget_code_before = $widget_code_after = '';
431
+
432
+ /*if ((!is_single() && array_key_exists('on_main', $options) && ($options['on_main'] == 1 )) or is_single()) {
433
+ switch ($options['widget_position']) {
434
+ case 'both':
435
+ return $widget_code.$content.$widget_code;//$widget_code_before = $widget_code_after = $widget_code;
436
+ break;
437
+ case 'top':
438
+ return $widget_code.$content; //$widget_code_before = $widget_code;
439
+ break;
440
+ case 'bottom':
441
+ return $content.$widget_code; //$widget_code_after = $widget_code;
442
+ break;
443
+ }
444
+ return $widget_code_before.$content.$widget_code_after;
445
+ }
446
+ */
447
+ if(!is_single()) {
448
+ if ($options['on_main'] == 1 ) {
449
+ switch ($options['widget_position']) {
450
+ case 'both':
451
+ return $widget_code.$content.$widget_code;
452
+ case 'top':
453
+ return $widget_code.$content;
454
+ case 'bottom':
455
+ return $content.$widget_code;
456
+ }
457
+ }
458
+ else return $content;
459
+ } else {
460
+ switch ($options['widget_position']) {
461
+ case 'both':
462
+ return $widget_code.$content.$widget_code;
463
+ case 'top':
464
+ return $widget_code.$content;
465
+ case 'bottom':
466
+ return $content.$widget_code;
467
+ }
468
+ };
469
+ } else {
470
+ return $content;
471
+ }
472
+ }
473
+
474
+ add_filter('the_content', 'add_widget', 100);
475
+
476
+
477
+ function uptolike_shortcode( $atts ){
478
+
479
+ return add_widget("");
480
+ }
481
+ add_shortcode( 'uptolike', 'uptolike_shortcode' );
482
+
483
+ function my_widgetcode_notice()
484
+ {
485
+ $options = get_option('my_option_name');
486
+ if (is_array($options) && array_key_exists('widget_code', $options)) {
487
+ $widget_code = $options['widget_code'];
488
+ if ('' == $widget_code) {
489
+ echo " <div class='updated'>
490
+ <p>В настройках UpToLike 'Конструктор' выберите тип виджета и нажмите 'Сохранить'</p>
491
+ </div>";
492
+ }
493
+ };
494
+ }
495
+
496
+ function logger($str)
497
+ {
498
+ file_put_contents(WP_PLUGIN_DIR . '/uptolike/log.txt', date(DATE_RFC822) . $str . PHP_EOL, FILE_APPEND | LOCK_EX);
499
+ }
500
+
501
+ function try_reg()
502
+ {
503
+ include('api_functions.php');
504
+ $domain = preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
505
+ $options = get_option('my_option_name');
506
+ $email = $options['uptolike_email'];
507
+ if ('' == $options['id_number']) {
508
+ $reg_ans = userReg($email, 'cms', 'cms' . $domain);
509
+ if (is_string($reg_ans)) {
510
+ $my_options = get_option('my_option_name');
511
+ $my_options['id_number'] = $reg_ans; // cryptkey store
512
+ $my_options['choice'] = 'reg';
513
+ update_option('my_option_name', $my_options);
514
+ };
515
+ update_option('reg_try', true);
516
+ }
517
+ }
518
+
519
+ function my_choice_notice()
520
+ {
521
+ $options = get_option('my_option_name');
522
+ if (is_bool($options) or (('' == $options['id_number']) and ((!array_key_exists('choice', $options)) OR ('ignore' !== $options['choice'])))) {
523
+ echo "<div class='updated'>
524
+ <div><img style='
525
+ float: left;
526
+ height: 38px;
527
+ margin-left: -9px;
528
+ margin-right: 5px;
529
+ ' src='//uptolike.ru/img/logo.png'>
530
+ </div>
531
+ Кнопки успешно установлены! <br>Для просмотра статистики необходимо:
532
+ <a href='options-general.php?page=uptolike_settings#enter'>Ввести полученный ключ</a>
533
+ | <a href='options-general.php?page=uptolike_settings#reg'>Запросить ключ</a>
534
+ | <a href='options-general.php?page=uptolike_settings&choice=ignore'>Скрыть</a> </div>";
535
+
536
+
537
+ };
538
+ }
539
+
540
+ function set_default_code()
541
+ {
542
+ $options = get_option('my_option_name');
543
+ if (is_bool($options)) {
544
+ $options = array();
545
+ }
546
+ $data_url = 'cms' . $_SERVER['HTTP_HOST'];
547
+ $data_pid = 'cms' . str_replace('.', '', preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']));
548
+ $code = <<<EOD
549
+ <script type="text/javascript">(function (w, doc) {
550
+ if (!w.__utlWdgt) {
551
+ w.__utlWdgt = true;
552
+ var d = doc, s = d.createElement('script'), g = 'getElementsByTagName';
553
+ s.type = 'text/javascript';
554
+ s.charset = 'UTF-8';
555
+ s.async = true;
556
+ s.src = ('https:' == w.location.protocol ? 'https' : 'http') + '://w.uptolike.com/widgets/v1/uptolike.js';
557
+ var h = d[g]('body')[0];
558
+ h.appendChild(s);
559
+ }
560
+ })(window, document);
561
+ </script>
562
+ <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">
563
+ </div>
564
+ EOD;
565
+
566
+ $code = str_replace('data-pid', 'data-pid="' . $data_pid . '"', $code);
567
+
568
+ $code = str_replace('data-url', 'data-url="' . $data_url . '"', $code);
569
+ $options['widget_code'] = $code;
570
+ $options['on_main'] = 1;
571
+ $options['widget_position'] = 'bottom';
572
+
573
+ update_option('my_option_name', $options);
574
+ }
575
+
576
+ function choice_helper($choice)
577
+ {
578
+ $options = get_option('my_option_name');
579
+ $options['choice'] = $choice;
580
+ if ('ignore' == $choice) {
581
+ set_default_code();
582
+ }
583
+ update_option('my_option_name', $options);
584
+ }
585
+
586
+ /*function usb_admin_bar() {
587
+ global $wp_admin_bar;
588
+
589
+ echo 'run usb admin bar';
590
+ //Add a link called at the top admin bar
591
+ $wp_admin_bar->add_node(array(
592
+ 'id' => 'UpToLike',
593
+ 'title' => 'UpToLike',
594
+ 'href' => admin_url( 'options-general.php?page=uptolike_settings', 'http' )
595
+ ));
596
+
597
+ }
598
+ */
599
+
600
+ function usb_admin_actions()
601
+ {
602
+ //echo 'run usb_admin_actions';
603
+ if ( current_user_can('manage_options') ) {
604
+ if (function_exists('add_meta_box')) {
605
+ add_menu_page("UpToLike", "UpToLike", "manage_options", "UpToLike", 'my_custom_menu_page', 'http://uptolike.com/favicon.ico');
606
+ } else {
607
+ // add_submenu_page("index.php", "UpToLike", "UpToLike", "manage_options", "UpToLike", "uptolike_settings", 'http://uptolike.com/favicon.ico');
608
+ } // end if addmeta box
609
+ if (get_option( OPTION_NAME_ENABLE_ADMIN_MENU, 'false' ) == 'true' ){
610
+ add_action( 'wp_before_admin_bar_render', 'usb_admin_bar' );
611
+ }
612
+
613
+ //wpo_detectDBType();
614
+ //wpo_PluginOptionsSetDefaults();
615
+ //wpo_cron_activate();
616
+ }
617
+ }
618
+
619
+ function my_custom_menu_page(){
620
+ include_once( 'usb-admin.php' );
621
+ }
622
+
623
+ register_activation_hook(__FILE__,'usb_admin_actions');
624
+ register_deactivation_hook(__FILE__,'usb_admin_actions_remove');
625
+
626
+ add_action('admin_notices', 'my_choice_notice');
627
+ add_action('admin_notices', 'my_widgetcode_notice');
628
+ add_action('admin_menu', 'usb_admin_actions');
629
+ //add_action( 'wp_before_admin_bar_render', 'wpo_admin_bar' );
630
+
631
+ $options = get_option('my_option_name');
632
+
633
+ if (is_admin()) {
634
+ $options = get_option('my_option_name');
635
+
636
+ if (array_key_exists('regme', $_REQUEST)) {
637
+ try_reg();
638
+ }
639
+ if (array_key_exists('choice', $_REQUEST)) {
640
+ choice_helper($_REQUEST['choice']);
641
+ }
642
+
643
+ $my_settings_page = new MySettingsPage();
644
+ if (is_bool($options) OR (!array_key_exists('widget_code', $options)) OR ('' == $options['widget_code'])) {
645
+ set_default_code();
646
+ }
647
+
648
+ }
uptolike_share_widget.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?
2
+ /*
3
+ Plugin Name: UpToLike Share Buttons
4
+ Plugin URI: http://uptolike.ru/
5
+ Description: Uptolike Share Buttons - social bookmarking widget with sharing statistics.
6
+ Version: 1.2.3
7
+ Author URI: http://uptolike.ru/
8
+ */
9
+
10
+
11
+ // Creating the widget
12
+
13
+ include 'widget_options.php';
uptolike_style.css ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ .id_number {
4
+ width: 520px;
5
+ }
6
+
7
+ h2.placeholder {
8
+ font-size: 1px;
9
+ padding: 1px;
10
+ margin: 0px;
11
+ height: 2px;
12
+ }
13
+
14
+ div.wrapper-tab {
15
+ display: none;
16
+ }
17
+
18
+ div.wrapper-tab.active {
19
+ display: block;
20
+ width: 100%;
21
+ }
22
+
usb-admin.php ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function constructorIframe($projectId, $partnerId, $mail, $cryptKey)
3
+ {
4
+
5
+ $params = array('mail' => $mail,
6
+ 'partner' => $partnerId,
7
+ 'projectId' => $projectId);
8
+
9
+ $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId . '&projectId=' . $projectId . $cryptKey;
10
+ $signature = md5($paramsStr);
11
+ $params['signature'] = $signature;
12
+ if ('' !== $cryptKey) {
13
+ $finalUrl = 'http://uptolike.com/api/constructor.html?' . http_build_query($params);
14
+ } else $finalUrl = 'http://uptolike.com/api/constructor.html';
15
+
16
+
17
+ return $finalUrl;
18
+ }
19
+
20
+ function statIframe($projectId, $partnerId, $mail, $cryptKey)
21
+ {
22
+ $params = array(
23
+ 'mail' => $mail,
24
+ 'partner' => $partnerId,
25
+ 'projectId' => $projectId,
26
+
27
+ );
28
+ $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId . '&projectId=' . $projectId;
29
+ $signature = md5($paramsStr . $cryptKey);
30
+ $params['signature'] = $signature;
31
+ $finalUrl = 'http://uptolike.com/api/statistics.html?' . http_build_query($params);
32
+
33
+ return $finalUrl;
34
+ }
35
+
36
+ function usb_admin_page()
37
+ {
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_settings('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
+ /* $this->options = get_option('my_option_name');
53
+
54
+ if ((isset($this->options['uptolike_email'])) && ('' !== $this->options['uptolike_email'])) {
55
+ $email = $this->options['uptolike_email'];
56
+ } else $email = get_settings('admin_email');
57
+ $partnerId = 'cms';
58
+ $projectId = 'cms' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);l
59
+ $projectId = str_replace('.','',$projectId);
60
+ $projectId = str_replace('-','',$projectId);
61
+ $options = get_option('my_option_name');
62
+ if (is_array($options) && array_key_exists('id_number', $options)) {
63
+ $cryptKey = $options['id_number'];
64
+ } else $cryptKey = '';
65
+ */
66
+ ?>
67
+ <script type="text/javascript">
68
+ <? include('main.js'); ?>
69
+ </script>
70
+ <style type="text/css">
71
+ h2.placeholder {
72
+ font-size: 1px;
73
+ padding: 1px;
74
+ margin: 0px;
75
+ height: 2px;
76
+ }
77
+
78
+ div.wrapper-tab {
79
+ display: none;
80
+ }
81
+
82
+ div.wrapper-tab.active {
83
+ display: block;
84
+ width: 100%;
85
+ }
86
+
87
+ input#id_number {
88
+ width: 520px;
89
+ }
90
+ </style>
91
+ <div class="wrap">
92
+ <h2 class="placeholder">&nbsp;</h2>
93
+
94
+ <div id="wrapper">
95
+ <form id="settings_form" method="post" action="options.php">
96
+ <H1> UpToLike виджет</H1>
97
+
98
+ <h2 class="nav-tab-wrapper">
99
+ <a class="nav-tab nav-tab-active" href="#" id="construct">
100
+ Конструктор
101
+ </a>
102
+ <a class="nav-tab" href="#" id="stat">
103
+ Статистика
104
+ </a>
105
+
106
+ <a class="nav-tab" href="#" id="settings">
107
+ Настройки
108
+ </a>
109
+ </h2>
110
+
111
+ <div class="wrapper-tab active" id="con_construct">
112
+ <iframe id='cons_iframe' style='height: 445px;width: 100%;'
113
+ data-src="<?php echo constructorIframe($projectId, $partnerId, $email, $cryptKey); ?>"></iframe>
114
+ <br>
115
+ <a onclick="getCode();" href="#">
116
+ <button type="reset">Сохранить изменения</button>
117
+ </a>
118
+ </div>
119
+ <div class="wrapper-tab" id="con_stat">
120
+ <? if (('' == $partnerId) OR ('' == $email) OR ('' == $cryptKey)) {
121
+
122
+ ?>
123
+ <h2>Статистика</h2>
124
+ <p>Для просмотра статистики необходимо ввести ваш секретный ключ </p>
125
+ <? } else { ?>
126
+ <!-- <?php print_r(array($partnerId, $email, $cryptKey)); ?> -->
127
+ <iframe style="width: 100%;height: 380px;" id="stats_iframe"
128
+ data-src="<?php echo statIframe($projectId, $partnerId, $email, $cryptKey); ?>">
129
+ </iframe> <?
130
+ } ?>
131
+ <button class="reg_btn" type="button">Запросить секретный ключ</button>
132
+ <br/>
133
+
134
+ <div class="reg_block">
135
+ <label>Email<input type="text" class="uptolike_email"></label><br/>
136
+ <button type="button" class="button-primary">Отправить ключ на email</button>
137
+ <br/>
138
+ </div>
139
+ <button class="enter_btn" type="button">Авторизация</button>
140
+ <br/>
141
+
142
+ <div class="enter_block">
143
+ <label>Email<input type="text" class="uptolike_email"></label><br/>
144
+ <label>Ключ<input type="text" class="id_number"></label><br/>
145
+ <button type="button" class="button-primary">Сохранить</button>
146
+ <br/>
147
+ </div>
148
+ </div>
149
+
150
+ <div class="wrapper-tab " id="con_settings">
151
+ <input type="hidden" name="option_page" value="my_option_group"><input type="hidden" name="action"
152
+ value="update"><input
153
+ type="hidden" id="_wpnonce" name="_wpnonce" value="cac4f73a65"><input type="hidden"
154
+ name="_wp_http_referer"
155
+ value="/wp-admin/options-general.php?page=uptolike_settings">
156
+
157
+ <h3>Настройки виджета</h3>
158
+ <table class="form-table">
159
+ <tbody>
160
+ <tr style="display:none">
161
+ <th scope="row">код виджета</th>
162
+ <td><textarea id="widget_code" name="my_option_name[widget_code]"></textarea></td>
163
+ </tr>
164
+ <tr style="display:none">
165
+ <th scope="row">Ключ(CryptKey)</th>
166
+ <td><input type="text" class="id_number" name="my_option_name[id_number]" value=""
167
+ style="width: 520px;"></td>
168
+ </tr>
169
+ <tr style="display:none">
170
+ <th scope="row">email для регистрации</th>
171
+ <td><input type="text" id="uptolike_email" name="my_option_name[uptolike_email]"
172
+ value="">
173
+ <button type="button" onclick="regMe();">Зарегистрироваться</button>
174
+ </td>
175
+ </tr>
176
+ <tr>
177
+ <th scope="row">Располагать блок на главной странице</th>
178
+ <td><input type="checkbox" id="on_main" name="my_option_name[on_main]" checked="checked">
179
+ </td>
180
+ </tr>
181
+ <tr>
182
+ <th scope="row">Расположение виджета</th>
183
+ <td><select id="widget_position" name="my_option_name[widget_position]">
184
+ <option value="top">Только сверху</option>
185
+ <option selected="selected" value="bottom">Только снизу</option>
186
+ <option value="both">Сверху и снизу</option>
187
+ </select></td>
188
+ </tr>
189
+ <tr>
190
+ <th scope="row">Обратная связь</th>
191
+ <td><a href="mailto:support@uptolike.com" target="_top"> support@uptolike.com</a></td>
192
+ </tr>
193
+ <tr style="display:none">
194
+ <th scope="row">настройки конструктора</th>
195
+ <td><input type="hidden" id="uptolike_json" name="my_option_name[uptolike_json]" value="">
196
+ </td>
197
+ </tr>
198
+ </tbody>
199
+ </table>
200
+ <input type="submit" name="submit_btn" value="Cохранить изменения">
201
+ </div>
202
+
203
+
204
+ </form>
205
+ </div>
206
+ </div>
207
+ <?php
208
+ }
209
+
210
+ usb_admin_page();
widget_options.php ADDED
@@ -0,0 +1,648 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class MySettingsPage
5
+ {
6
+
7
+ private $options;
8
+ private $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
+ }
14
+
15
+
16
+ public function add_plugin_page()
17
+ {
18
+ add_options_page(
19
+ 'Settings Admin',
20
+ 'UpToLike',
21
+ 'manage_options',
22
+ $this->settings_page_name, //'my-setting-admin',
23
+ array($this, 'create_admin_page')
24
+ );
25
+ }
26
+
27
+ /** creates url of iframe with statistics page from given params
28
+ *
29
+ * @param $projectId
30
+ * @param $partnerId
31
+ * @param $mail
32
+ * @param $cryptKey
33
+ * @return stringшfr
34
+ */
35
+ public function statIframe($projectId, $partnerId, $mail, $cryptKey)
36
+ {
37
+ $params = array(
38
+ 'mail' => $mail,
39
+ 'partner' => $partnerId,
40
+ 'projectId' => $projectId,
41
+
42
+ );
43
+ $paramsStr = 'mail=' . $mail . '&partner=' . $partnerId. '&projectId=' . $projectId;
44
+ $signature = md5($paramsStr . $cryptKey);
45
+ $params['signature'] = $signature;
46
+ $finalUrl = 'http://uptolike.com/api/statistics.html?' . http_build_query($params);
47
+
48
+ return $finalUrl;
49
+ }
50
+
51
+ /** create url of iframe with constructor from given params
52
+ * @param $projectId
53
+ * @param $partnerId
54
+ * @param $mail
55
+ * @param $cryptKey
56
+ * @return string
57
+ */
58
+ public function constructorIframe($projectId, $partnerId, $mail, $cryptKey)
59
+ {
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 = 'http://uptolike.com/api/constructor.html?' . http_build_query($params);
70
+ } else $finalUrl = 'http://uptolike.com/api/constructor.html';
71
+
72
+
73
+ return $finalUrl;
74
+ }
75
+
76
+
77
+ /** returns tabs html code. May be replace by proper html code
78
+ * @param string $current
79
+ */
80
+ public function ilc_admin_tabs($current = 'construct')
81
+ {
82
+ $tabs = array('construct' => 'Конструктор',
83
+ 'stat' => 'Статистика',
84
+ 'settings' => 'Настройки');
85
+
86
+ echo '<div id="icon-themes" class="icon32"><br></div>';
87
+ echo '<h2 class="nav-tab-wrapper">';
88
+ foreach ($tabs as $tab => $name) {
89
+ $class = ($tab == $current) ? ' nav-tab-active' : '';
90
+ echo "<a class='nav-tab$class' href='#' id=" . $tab . " ref='?page=" . $this->settings_page_name . "&tab=$tab'>$name</a>";
91
+
92
+ }
93
+ echo '</h2>';
94
+ }
95
+
96
+ /** render html page with code configuration settings
97
+ *
98
+ */
99
+ public function create_admin_page()
100
+ {
101
+ $this->options = get_option('my_option_name');
102
+
103
+ if ((isset($this->options['uptolike_email'])) && ('' !== $this->options['uptolike_email'])) {
104
+ $email = $this->options['uptolike_email'];
105
+ } else $email = get_settings('admin_email');
106
+ $partnerId = 'cms';
107
+ $projectId = 'cms' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
108
+ $projectId = str_replace('.','',$projectId);
109
+ $projectId = str_replace('-','',$projectId);
110
+ $options = get_option('my_option_name');
111
+ if (is_array($options) && array_key_exists('id_number', $options)) {
112
+ $cryptKey = $options['id_number'];
113
+ } else $cryptKey = '';
114
+ ?>
115
+ <script type="text/javascript">
116
+ <? include('main.js'); ?>
117
+ </script>
118
+ <style type="text/css">
119
+ h2.placeholder {
120
+ font-size: 1px;
121
+ padding: 1px;
122
+ margin: 0px;
123
+ height: 2px;
124
+ }
125
+
126
+ div.wrapper-tab {
127
+ display: none;
128
+ }
129
+
130
+ div.wrapper-tab.active {
131
+ display: block;
132
+ width: 100%;
133
+ }
134
+
135
+ input#id_number {
136
+ width: 520px;
137
+ }
138
+ </style>
139
+ <div class="wrap">
140
+ <h2 class="placeholder">&nbsp;</h2>
141
+ <div id="wrapper">
142
+ <form id="settings_form" method="post" action="options.php">
143
+ <H1> UpToLike виджет</H1>
144
+ <h2 class="nav-tab-wrapper">
145
+ <a class="nav-tab nav-tab-active" href="#" id="construct">
146
+ Конструктор
147
+ </a>
148
+ <a class="nav-tab" href="#" id="stat">
149
+ Статистика
150
+ </a>
151
+
152
+ <a class="nav-tab" href="#" id="settings">
153
+ Настройки
154
+ </a>
155
+ </h2>
156
+ <div class="wrapper-tab active" id="con_construct">
157
+ <iframe id='cons_iframe' style='height: 445px;width: 100%;' data-src="<?php echo $this->constructorIframe($projectId, $partnerId, $email, $cryptKey); ?>"></iframe>
158
+ <br>
159
+ <a onclick="getCode();" href="#">
160
+ <button type="reset">Сохранить изменения</button>
161
+ </a>
162
+ </div>
163
+ <div class="wrapper-tab" id="con_stat">
164
+ <? if (('' == $partnerId) OR ('' == $email) OR ('' == $cryptKey)) {
165
+
166
+ ?>
167
+ <h2>Статистика</h2>
168
+ <p>Для просмотра статистики необходимо ввести ваш секретный ключ </p>
169
+ <? } else { ?>
170
+ <!-- <?php print_r(array($partnerId,$email, $cryptKey)); ?> -->
171
+ <iframe style="width: 100%;height: 380px;" id="stats_iframe" data-src="<?php echo $this->statIframe($projectId, $partnerId, $email, $cryptKey); ?>">
172
+ </iframe> <?
173
+ } ?>
174
+ <button class="reg_btn" type="button">Запросить секретный ключ</button><br/>
175
+ <div class="reg_block">
176
+ <label>Email<input type="text" class="uptolike_email"></label><br/>
177
+ <button type="button" class="button-primary">Отправить ключ на email</button><br/>
178
+ </div>
179
+ <button class="enter_btn" type="button">Авторизация</button><br/>
180
+ <div class="enter_block" >
181
+ <label>Email<input type="text" class="uptolike_email"></label><br/>
182
+ <label>Ключ<input type="text" class="id_number"></label><br/>
183
+ <button type="button" class="button-primary">Сохранить</button><br/>
184
+ </div>
185
+ </div>
186
+ <div class="wrapper-tab" id="con_settings">
187
+ <?php
188
+ settings_fields('my_option_group');
189
+ do_settings_sections($this->settings_page_name);
190
+ ?>
191
+ <input type="submit" name="submit_btn" value="Cохранить изменения">
192
+ </div>
193
+
194
+ </form>
195
+ </div>
196
+ </div>
197
+ <?php
198
+ }
199
+
200
+ public function page_init()
201
+ {
202
+ register_setting(
203
+ 'my_option_group', // Option group
204
+ 'my_option_name', // Option name
205
+ array($this, 'sanitize') // Sanitize
206
+ );
207
+
208
+ add_settings_section(
209
+ 'setting_section_id', // ID
210
+ 'Настройки виджета', // Title
211
+ array($this, 'print_section_info'), // Callback
212
+ $this->settings_page_name//'my-setting-admin' // Page
213
+ );
214
+
215
+ add_settings_field(
216
+ 'widget_code', // ID
217
+ 'код виджета', // Title
218
+ array($this, 'widget_code_callback'), // Callback
219
+ $this->settings_page_name, //'my-setting-admin', // Page
220
+ 'setting_section_id' // Section
221
+ );
222
+
223
+ add_settings_field(
224
+ 'data_pid', // ID
225
+ 'Ключ(CryptKey)', // Title
226
+ array($this, 'id_number_callback'), // Callback
227
+ $this->settings_page_name, //'my-setting-admin', // Page
228
+ 'setting_section_id' // Section
229
+ );
230
+
231
+ add_settings_field(
232
+ 'email', //ID
233
+ 'email для регистрации',
234
+ array($this, 'uptolike_email_callback'),
235
+ $this->settings_page_name, //'my-setting-admin',
236
+ 'setting_section_id'
237
+ );
238
+
239
+ add_settings_field(
240
+ 'on_main', //ID
241
+ 'Располагать блок на главной странице',
242
+ array($this, 'uptolike_on_main_callback'),
243
+ $this->settings_page_name, //'my-setting-admin',
244
+ 'setting_section_id'
245
+ );
246
+
247
+ add_settings_field(
248
+ 'widget_position', //ID
249
+ 'Расположение виджета',
250
+ array($this, 'uptolike_widget_position_callback'),
251
+ $this->settings_page_name, //'my-setting-admin',
252
+ 'setting_section_id'
253
+ );
254
+
255
+ add_settings_field(
256
+ 'feedback', //ID
257
+ 'Обратная связь',
258
+ array($this, 'uptolike_feedback_callback'),
259
+ $this->settings_page_name, //'my-setting-admin',
260
+ 'setting_section_id'
261
+ );
262
+
263
+
264
+ add_settings_field(
265
+ 'uptolike_json', //ID
266
+ 'настройки конструктора',
267
+ array($this, 'uptolike_json_callback'),
268
+ $this->settings_page_name, //'my-setting-admin',
269
+ 'setting_section_id'
270
+ );
271
+ }
272
+
273
+ /**
274
+ * Sanitize each setting field as needed
275
+ *
276
+ * @param array $input Contains all settings fields as array keys
277
+ */
278
+ public function sanitize($input)
279
+ {
280
+ $new_input = array();
281
+ if (isset($input['id_number']))
282
+ $new_input['id_number'] = str_replace(' ','',$input['id_number']);
283
+
284
+ if (isset($input['widget_code']))
285
+ $new_input['widget_code'] = $input['widget_code'];
286
+
287
+ if (isset($input['uptolike_email']))
288
+ $new_input['uptolike_email'] = $input['uptolike_email'];
289
+
290
+ if (isset($input['before_content']))
291
+ $new_input['before_content'] = $input['before_content'];
292
+
293
+ if (isset($input['on_main'])) {
294
+ $new_input['on_main'] = 1;
295
+ } else $new_input['on_main'] = 0;
296
+
297
+ if (isset($input['email']))
298
+ $new_input['email'] = $input['email'];
299
+
300
+ if (isset($input['after_content']))
301
+ $new_input['after_content'] = $input['after_content'];
302
+
303
+ if (isset($input['widget_position']))
304
+ $new_input['widget_position'] = $input['widget_position'];
305
+
306
+ if (isset($input['uptolike_json']))
307
+ $new_input['uptolike_json'] = $input['uptolike_json'];
308
+
309
+ return $new_input;
310
+ }
311
+
312
+
313
+ public function print_section_info()
314
+ {
315
+ //print 'Enter your settings below:';
316
+ }
317
+
318
+ public function widget_code_callback()
319
+ {
320
+ printf(
321
+ '<textarea id="widget_code" name="my_option_name[widget_code]" >%s</textarea>',
322
+ isset($this->options['widget_code']) ? esc_attr($this->options['widget_code']) : ''
323
+ );
324
+ }
325
+
326
+ /** 12536473050877
327
+ * Get the settings option array and print one of its values
328
+ */
329
+ public function id_number_callback()
330
+ {
331
+ printf(
332
+ '<input type="text" class="id_number" name="my_option_name[id_number]" value="%s" />',
333
+ isset($this->options['id_number']) ? esc_attr($this->options['id_number']) : ''
334
+ );
335
+ }
336
+
337
+ public function uptolike_email_callback()
338
+ {
339
+ printf(
340
+ '<input type="text" id="uptolike_email" name="my_option_name[uptolike_email]" value="%s" />',
341
+ isset($this->options['uptolike_email']) ? esc_attr($this->options['uptolike_email']) : get_settings('admin_email')
342
+ );
343
+ }
344
+
345
+ public function uptolike_json_callback()
346
+ {
347
+ printf(
348
+ '<input type="hidden" id="uptolike_json" name="my_option_name[uptolike_json]" value="%s" />',
349
+ isset($this->options['uptolike_json']) ? esc_attr($this->options['uptolike_json']) : ''
350
+ );
351
+ }
352
+
353
+ public function uptolike_partner_id_callback()
354
+ {
355
+ printf(
356
+ '<input type="text" id="uptolike_partner" name="my_option_name[uptolike_partner]" value="%s" />',
357
+ isset($this->options['uptolike_partner']) ? esc_attr($this->options['uptolike_partner']) : ''
358
+ );
359
+ }
360
+
361
+ public function uptolike_feedback_callback()
362
+ {
363
+ echo '<a href="mailto:support@uptolike.com" target="_top"> support@uptolike.com</a>';
364
+ }
365
+
366
+ public function uptolike_project_callback()
367
+ {
368
+ printf(
369
+ '<input type="text" id="uptolike_project" name="my_option_name[uptolike_project]" value="%s" />',
370
+ isset($this->options['uptolike_project']) ? esc_attr($this->options['uptolike_project']) : ''
371
+ );
372
+ }
373
+
374
+ public function uptolike_on_main_callback()
375
+ {
376
+ echo '<input type="checkbox" id="on_main" name="my_option_name[on_main]"';
377
+ echo ($this->options['on_main'] == '1' ? 'checked="checked"' : ''); echo ' />';
378
+
379
+ }
380
+
381
+
382
+ public function uptolike_widget_position_callback()
383
+ {
384
+ $top = $bottom = $both = $default = '';
385
+
386
+ if (isset($this->options['widget_position'])) {
387
+ if ('top' == $this->options['widget_position']) {
388
+ $top = "selected='selected'";
389
+ } elseif ('bottom' == $this->options['widget_position']) {
390
+ $bottom = "selected='selected'";
391
+ } elseif ('both' == $this->options['widget_position']) {
392
+ $both = "selected='selected'";
393
+ } else {
394
+ $bottom = "selected='selected'";
395
+ }
396
+ } else {
397
+ $my_options = get_option('my_option_name');
398
+ $my_options['widget_position'] = 'bottom'; // cryptkey store
399
+ update_option('my_option_name', $my_options);
400
+ }
401
+ $default = "selected='selected'";
402
+ echo "<select id='widget_position' name='my_option_name[widget_position]'>
403
+ <option {$top} value='top'>Только сверху</option>
404
+ <option {$bottom} value='bottom'>Только снизу</option>
405
+ <option {$both} value='both'>Сверху и снизу</option>
406
+ </select>";
407
+
408
+ }
409
+
410
+ }
411
+
412
+
413
+ function add_widget($content)
414
+ {
415
+ //print_r($options = get_option('my_option_name'));
416
+ //return $content;
417
+
418
+ $options = get_option('my_option_name');
419
+ if (is_array($options) && array_key_exists('widget_code', $options)) {
420
+ $widget_code = $options['widget_code'];
421
+ $url = get_permalink();
422
+
423
+ //fixing bad data-pid
424
+ $domain = preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
425
+ $data_pid = 'cms' . str_replace('.', '', $domain);
426
+
427
+ $widget_code = str_replace('data-pid="-1"','data-pid="' . $data_pid . '"',$widget_code);
428
+ $widget_code = str_replace('data-pid=""','data-pid="' . $data_pid . '"',$widget_code);
429
+ $widget_code = str_replace('div data', 'div data-url="' . $url . '" data', $widget_code);
430
+ $widget_code_before = $widget_code_after = '';
431
+
432
+ /*if ((!is_single() && array_key_exists('on_main', $options) && ($options['on_main'] == 1 )) or is_single()) {
433
+ switch ($options['widget_position']) {
434
+ case 'both':
435
+ return $widget_code.$content.$widget_code;//$widget_code_before = $widget_code_after = $widget_code;
436
+ break;
437
+ case 'top':
438
+ return $widget_code.$content; //$widget_code_before = $widget_code;
439
+ break;
440
+ case 'bottom':
441
+ return $content.$widget_code; //$widget_code_after = $widget_code;
442
+ break;
443
+ }
444
+ return $widget_code_before.$content.$widget_code_after;
445
+ }
446
+ */
447
+ if(!is_single()) {
448
+ if ($options['on_main'] == 1 ) {
449
+ switch ($options['widget_position']) {
450
+ case 'both':
451
+ return $widget_code.$content.$widget_code;
452
+ case 'top':
453
+ return $widget_code.$content;
454
+ case 'bottom':
455
+ return $content.$widget_code;
456
+ }
457
+ }
458
+ else return $content;
459
+ } else {
460
+ switch ($options['widget_position']) {
461
+ case 'both':
462
+ return $widget_code.$content.$widget_code;
463
+ case 'top':
464
+ return $widget_code.$content;
465
+ case 'bottom':
466
+ return $content.$widget_code;
467
+ }
468
+ };
469
+ } else {
470
+ return $content;
471
+ }
472
+ }
473
+
474
+ add_filter('the_content', 'add_widget', 100);
475
+
476
+
477
+ function uptolike_shortcode( $atts ){
478
+
479
+ return add_widget("");
480
+ }
481
+ add_shortcode( 'uptolike', 'uptolike_shortcode' );
482
+
483
+ function my_widgetcode_notice()
484
+ {
485
+ $options = get_option('my_option_name');
486
+ if (is_array($options) && array_key_exists('widget_code', $options)) {
487
+ $widget_code = $options['widget_code'];
488
+ if ('' == $widget_code) {
489
+ echo " <div class='updated'>
490
+ <p>В настройках UpToLike 'Конструктор' выберите тип виджета и нажмите 'Сохранить'</p>
491
+ </div>";
492
+ }
493
+ };
494
+ }
495
+
496
+ function logger($str)
497
+ {
498
+ file_put_contents(WP_PLUGIN_DIR . '/uptolike/log.txt', date(DATE_RFC822) . $str . PHP_EOL, FILE_APPEND | LOCK_EX);
499
+ }
500
+
501
+ function try_reg()
502
+ {
503
+ include('api_functions.php');
504
+ $domain = preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
505
+ $options = get_option('my_option_name');
506
+ $email = $options['uptolike_email'];
507
+ if ('' == $options['id_number']) {
508
+ $reg_ans = userReg($email, 'cms', 'cms' . $domain);
509
+ if (is_string($reg_ans)) {
510
+ $my_options = get_option('my_option_name');
511
+ $my_options['id_number'] = $reg_ans; // cryptkey store
512
+ $my_options['choice'] = 'reg';
513
+ update_option('my_option_name', $my_options);
514
+ };
515
+ update_option('reg_try', true);
516
+ }
517
+ }
518
+
519
+ function my_choice_notice()
520
+ {
521
+ $options = get_option('my_option_name');
522
+ if (is_bool($options) or (('' == $options['id_number']) and ((!array_key_exists('choice', $options)) OR ('ignore' !== $options['choice'])))) {
523
+ echo "<div class='updated'>
524
+ <div><img style='
525
+ float: left;
526
+ height: 38px;
527
+ margin-left: -9px;
528
+ margin-right: 5px;
529
+ ' src='//uptolike.ru/img/logo.png'>
530
+ </div>
531
+ Кнопки успешно установлены! <br>Для просмотра статистики необходимо:
532
+ <a href='options-general.php?page=uptolike_settings#enter'>Ввести полученный ключ</a>
533
+ | <a href='options-general.php?page=uptolike_settings#reg'>Запросить ключ</a>
534
+ | <a href='options-general.php?page=uptolike_settings&choice=ignore'>Скрыть</a> </div>";
535
+
536
+
537
+ };
538
+ }
539
+
540
+ function set_default_code()
541
+ {
542
+ $options = get_option('my_option_name');
543
+ if (is_bool($options)) {
544
+ $options = array();
545
+ }
546
+ $data_url = 'cms' . $_SERVER['HTTP_HOST'];
547
+ $data_pid = 'cms' . str_replace('.', '', preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']));
548
+ $code = <<<EOD
549
+ <script type="text/javascript">(function (w, doc) {
550
+ if (!w.__utlWdgt) {
551
+ w.__utlWdgt = true;
552
+ var d = doc, s = d.createElement('script'), g = 'getElementsByTagName';
553
+ s.type = 'text/javascript';
554
+ s.charset = 'UTF-8';
555
+ s.async = true;
556
+ s.src = ('https:' == w.location.protocol ? 'https' : 'http') + '://w.uptolike.com/widgets/v1/uptolike.js';
557
+ var h = d[g]('body')[0];
558
+ h.appendChild(s);
559
+ }
560
+ })(window, document);
561
+ </script>
562
+ <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">
563
+ </div>
564
+ EOD;
565
+
566
+ $code = str_replace('data-pid', 'data-pid="' . $data_pid . '"', $code);
567
+
568
+ $code = str_replace('data-url', 'data-url="' . $data_url . '"', $code);
569
+ $options['widget_code'] = $code;
570
+ $options['on_main'] = 1;
571
+ $options['widget_position'] = 'bottom';
572
+
573
+ update_option('my_option_name', $options);
574
+ }
575
+
576
+ function choice_helper($choice)
577
+ {
578
+ $options = get_option('my_option_name');
579
+ $options['choice'] = $choice;
580
+ if ('ignore' == $choice) {
581
+ set_default_code();
582
+ }
583
+ update_option('my_option_name', $options);
584
+ }
585
+
586
+ /*function usb_admin_bar() {
587
+ global $wp_admin_bar;
588
+
589
+ echo 'run usb admin bar';
590
+ //Add a link called at the top admin bar
591
+ $wp_admin_bar->add_node(array(
592
+ 'id' => 'UpToLike',
593
+ 'title' => 'UpToLike',
594
+ 'href' => admin_url( 'options-general.php?page=uptolike_settings', 'http' )
595
+ ));
596
+
597
+ }
598
+ */
599
+
600
+ function usb_admin_actions()
601
+ {
602
+ //echo 'run usb_admin_actions';
603
+ if ( current_user_can('manage_options') ) {
604
+ if (function_exists('add_meta_box')) {
605
+ add_menu_page("UpToLike", "UpToLike", "manage_options", "UpToLike", 'my_custom_menu_page', 'http://uptolike.com/favicon.ico');
606
+ } else {
607
+ // add_submenu_page("index.php", "UpToLike", "UpToLike", "manage_options", "UpToLike", "uptolike_settings", 'http://uptolike.com/favicon.ico');
608
+ } // end if addmeta box
609
+ if (get_option( OPTION_NAME_ENABLE_ADMIN_MENU, 'false' ) == 'true' ){
610
+ add_action( 'wp_before_admin_bar_render', 'usb_admin_bar' );
611
+ }
612
+
613
+ //wpo_detectDBType();
614
+ //wpo_PluginOptionsSetDefaults();
615
+ //wpo_cron_activate();
616
+ }
617
+ }
618
+
619
+ function my_custom_menu_page(){
620
+ include_once( 'usb-admin.php' );
621
+ }
622
+
623
+ register_activation_hook(__FILE__,'usb_admin_actions');
624
+ register_deactivation_hook(__FILE__,'usb_admin_actions_remove');
625
+
626
+ add_action('admin_notices', 'my_choice_notice');
627
+ add_action('admin_notices', 'my_widgetcode_notice');
628
+ add_action('admin_menu', 'usb_admin_actions');
629
+ //add_action( 'wp_before_admin_bar_render', 'wpo_admin_bar' );
630
+
631
+ $options = get_option('my_option_name');
632
+
633
+ if (is_admin()) {
634
+ $options = get_option('my_option_name');
635
+
636
+ if (array_key_exists('regme', $_REQUEST)) {
637
+ try_reg();
638
+ }
639
+ if (array_key_exists('choice', $_REQUEST)) {
640
+ choice_helper($_REQUEST['choice']);
641
+ }
642
+
643
+ $my_settings_page = new MySettingsPage();
644
+ if (is_bool($options) OR (!array_key_exists('widget_code', $options)) OR ('' == $options['widget_code'])) {
645
+ set_default_code();
646
+ }
647
+
648
+ }