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