Version Description
- Bug fix
Download this release
Release Info
Developer | na1vez |
Plugin | Uptolike Social Share Buttons |
Version | 1.3.6 |
Comparing to | |
See all releases |
Version 1.3.6
- api_functions.php +68 -0
- logo-small.png +0 -0
- main.js +164 -0
- readme.txt +126 -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 +13 -0
- uptolike_style.css +22 -0
- usb-admin.php +178 -0
- widget_options.php +851 -0
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 |
+
|
logo-small.png
ADDED
Binary file
|
main.js
ADDED
@@ -0,0 +1,164 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
if (e.data.url.indexOf('constructor.html', 0) != -1) {
|
14 |
+
document.getElementById("cons_iframe").style.height = e.data.size + 'px';
|
15 |
+
}
|
16 |
+
if (e.data.url.indexOf('statistics.html', 0) != -1) {
|
17 |
+
document.getElementById("stats_iframe").style.height = e.data.size + 'px';
|
18 |
+
}
|
19 |
+
|
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 ('#settings' == hsh) {
|
68 |
+
// $('.nav-tab-wrapper a').removeClass('nav-tab-active');
|
69 |
+
// $('a.nav-tab#settings').addClass('nav-tab-active');
|
70 |
+
// $('.wrapper-tab').removeClass('active');
|
71 |
+
// $('#con_settings').addClass('active');
|
72 |
+
// }
|
73 |
+
|
74 |
+
// else
|
75 |
+
if (('#reg' == hsh) || ('#enter' == hsh)) {
|
76 |
+
|
77 |
+
$('.nav-tab-wrapper a').removeClass('nav-tab-active');
|
78 |
+
$('a.nav-tab#stat').addClass('nav-tab-active');
|
79 |
+
$('.wrapper-tab').removeClass('active');
|
80 |
+
$('#con_stat').addClass('active');
|
81 |
+
|
82 |
+
if ('#reg' == hsh) {
|
83 |
+
$('.reg_btn').show();
|
84 |
+
$('.reg_block').show();
|
85 |
+
$('.enter_btn').hide();
|
86 |
+
$('.enter_block').hide();
|
87 |
+
}
|
88 |
+
if ('#enter' == hsh) {
|
89 |
+
$('.reg_btn').hide();
|
90 |
+
$('.reg_block').hide();
|
91 |
+
$('.enter_btn').show();
|
92 |
+
$('.enter_block').show();
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
window.onhashchange = function() {
|
98 |
+
hashChange();
|
99 |
+
}
|
100 |
+
|
101 |
+
jQuery(document).ready(function () {
|
102 |
+
$ = jQuery;
|
103 |
+
|
104 |
+
$('input.id_number').css('width','520px');//fix
|
105 |
+
$('.uptolike_email').val($('#uptolike_email').val())//init fields with hidden value (server email)
|
106 |
+
$('.enter_block input.id_number').attr('value', $('table input.id_number').val());
|
107 |
+
|
108 |
+
$('div.enter_block').hide();
|
109 |
+
$('div.reg_block').hide();
|
110 |
+
|
111 |
+
$('.reg_btn').click(function(){
|
112 |
+
$('.reg_block').toggle('fast');
|
113 |
+
$('.enter_btn').toggle('fast');
|
114 |
+
})
|
115 |
+
|
116 |
+
$('.enter_btn').click(function(){
|
117 |
+
$('.enter_block').toggle('fast');
|
118 |
+
$('.reg_btn').toggle('fast');
|
119 |
+
})
|
120 |
+
|
121 |
+
$('.reg_block button').click(function(){
|
122 |
+
my_email = $('.reg_block .uptolike_email').val();
|
123 |
+
regMe(my_email);
|
124 |
+
})
|
125 |
+
|
126 |
+
$('.enter_block button').click(function(){
|
127 |
+
my_email = $('.enter_block input.uptolike_email').val();
|
128 |
+
my_key = $('.enter_block input.id_number').val();
|
129 |
+
$('table input.id_number').attr('value',my_key);
|
130 |
+
$('table input#uptolike_email').attr('value',my_email);
|
131 |
+
$('#settings_form').submit();
|
132 |
+
})
|
133 |
+
|
134 |
+
//if unregged user
|
135 |
+
if ($('.id_number').val() == '') {
|
136 |
+
$('#uptolike_email').after('<button type="button" onclick="regMe();">Зарегистрироваться</button>');
|
137 |
+
json = $('input#uptolike_json').val();
|
138 |
+
initConstr(json);
|
139 |
+
}
|
140 |
+
$('#widget_code').parent().parent().attr('style', 'display:none');
|
141 |
+
$('#uptolike_json').parent().parent().attr('style', 'display:none')
|
142 |
+
$('table .id_number').parent().parent().attr('style', 'display:none')
|
143 |
+
$('#uptolike_email').parent().parent().attr('style', 'display:none')
|
144 |
+
|
145 |
+
$('.nav-tab-wrapper a').click(function (e) {
|
146 |
+
e.preventDefault();
|
147 |
+
var click_id = $(this).attr('id');
|
148 |
+
if (click_id != $('.nav-tab-wrapper a.nav-tab-active').attr('id')) {
|
149 |
+
$('.nav-tab-wrapper a').removeClass('nav-tab-active');
|
150 |
+
$(this).addClass('nav-tab-active');
|
151 |
+
$('.wrapper-tab').removeClass('active');
|
152 |
+
$('#con_' + click_id).addClass('active');
|
153 |
+
}
|
154 |
+
});
|
155 |
+
|
156 |
+
hashChange();
|
157 |
+
$.getScript( "http://uptolike.com/api/getsession.json" )
|
158 |
+
.done(function( script, textStatus ) {
|
159 |
+
$('iframe#cons_iframe').attr('src',$('iframe#cons_iframe').attr('data-src'));
|
160 |
+
$('iframe#stats_iframe').attr('src',$('iframe#stats_iframe').attr('data-src'));
|
161 |
+
});
|
162 |
+
|
163 |
+
});
|
164 |
+
|
readme.txt
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.1
|
6 |
+
Stable tag: 1.3.6
|
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.3.6 =
|
70 |
+
* Bug fix
|
71 |
+
|
72 |
+
= 1.3.5 =
|
73 |
+
* Enahncement: new align and shortcode settings
|
74 |
+
|
75 |
+
= 1.3.4 =
|
76 |
+
* Bug fix
|
77 |
+
|
78 |
+
= 1.3.3 =
|
79 |
+
* Enhancement
|
80 |
+
|
81 |
+
= 1.3.2 =
|
82 |
+
* Bug fix
|
83 |
+
|
84 |
+
= 1.3.1 =
|
85 |
+
* Enahncement: widget area
|
86 |
+
|
87 |
+
= 1.3.0 =
|
88 |
+
* Bug fix
|
89 |
+
|
90 |
+
= 1.2.9 =
|
91 |
+
* Bug Fix: minor changes
|
92 |
+
|
93 |
+
= 1.2.8 =
|
94 |
+
* Enhancement: new settings
|
95 |
+
* Bug Fix
|
96 |
+
|
97 |
+
= 1.2.7 =
|
98 |
+
* Bug Fix: minor bug fixes
|
99 |
+
|
100 |
+
= 1.2.6 =
|
101 |
+
* Enhancement: new feature - on archive
|
102 |
+
|
103 |
+
= 1.2.5 =
|
104 |
+
* Bug fix: minor bugs with short tag option
|
105 |
+
|
106 |
+
= 1.2.4 =
|
107 |
+
* Enhancement: new feature - on static page
|
108 |
+
* Enhancement: security
|
109 |
+
* Bug fix
|
110 |
+
|
111 |
+
= 1.2.3 =
|
112 |
+
* Bug fix: show on main
|
113 |
+
|
114 |
+
= 1.2.2 =
|
115 |
+
* Enhancement: cut spaces in cryptkey field
|
116 |
+
* Enhancement: feedback link
|
117 |
+
* Enhancement: access to plugins by top menu item
|
118 |
+
|
119 |
+
= 1.2.1 =
|
120 |
+
* Bug Fix: minor bug fixes
|
121 |
+
|
122 |
+
= 1.2.0 =
|
123 |
+
* Enhancement: user registration.
|
124 |
+
|
125 |
+
= 1.0.0 =
|
126 |
+
* 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,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.6
|
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,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/* $this->options = get_option('my_option_name');
|
56 |
+
|
57 |
+
if ((isset($this->options['uptolike_email'])) && ('' !== $this->options['uptolike_email'])) {
|
58 |
+
$email = $this->options['uptolike_email'];
|
59 |
+
} else $email = get_option('admin_email');
|
60 |
+
$partnerId = 'cms';
|
61 |
+
$projectId = 'cms' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);l
|
62 |
+
$projectId = str_replace('.','',$projectId);
|
63 |
+
$projectId = str_replace('-','',$projectId);
|
64 |
+
$options = get_option('my_option_name');
|
65 |
+
if (is_array($options) && array_key_exists('id_number', $options)) {
|
66 |
+
$cryptKey = $options['id_number'];
|
67 |
+
} else $cryptKey = '';
|
68 |
+
*/
|
69 |
+
?>
|
70 |
+
<script type="text/javascript">
|
71 |
+
<?php include('main.js'); ?>
|
72 |
+
</script>
|
73 |
+
<style type="text/css">
|
74 |
+
h2.placeholder {
|
75 |
+
font-size: 1px;
|
76 |
+
padding: 1px;
|
77 |
+
margin: 0px;
|
78 |
+
height: 2px;
|
79 |
+
}
|
80 |
+
|
81 |
+
div.wrapper-tab {
|
82 |
+
display: none;
|
83 |
+
}
|
84 |
+
|
85 |
+
div.wrapper-tab.active {
|
86 |
+
display: block;
|
87 |
+
width: 100%;
|
88 |
+
}
|
89 |
+
|
90 |
+
input#id_number {
|
91 |
+
width: 520px;
|
92 |
+
}
|
93 |
+
</style>
|
94 |
+
<div class="wrap">
|
95 |
+
<h2 class="placeholder"> </h2>
|
96 |
+
|
97 |
+
<div id="wrapper">
|
98 |
+
<form id="settings_form" method="post" action="options.php">
|
99 |
+
<H1> UpToLike виджет</H1>
|
100 |
+
|
101 |
+
<h2 class="nav-tab-wrapper">
|
102 |
+
<a class="nav-tab nav-tab-active" href="#" id="construct">
|
103 |
+
Конструктор
|
104 |
+
</a>
|
105 |
+
<a class="nav-tab" href="#" id="stat">
|
106 |
+
Статистика
|
107 |
+
</a>
|
108 |
+
|
109 |
+
<a class="nav-tab" href="#" id="settings">
|
110 |
+
Настройки
|
111 |
+
</a>
|
112 |
+
</h2>
|
113 |
+
|
114 |
+
<div class="wrapper-tab active" id="con_construct">
|
115 |
+
<iframe id='cons_iframe' style='height: 445px;width: 100%;'
|
116 |
+
data-src="<?php echo constructorIframe($projectId, $partnerId, $email, $cryptKey); ?>"></iframe>
|
117 |
+
<br>
|
118 |
+
<a onclick="getCode();" href="#">
|
119 |
+
<button type="reset">Сохранить изменения</button>
|
120 |
+
</a>
|
121 |
+
</div>
|
122 |
+
<div class="wrapper-tab" id="con_stat">
|
123 |
+
<?php if (('' == $partnerId) OR ('' == $email) OR ('' == $cryptKey)) {
|
124 |
+
|
125 |
+
?>
|
126 |
+
<h2>Статистика</h2>
|
127 |
+
<p>Для просмотра статистики необходимо ввести ваш секретный ключ </p>
|
128 |
+
<?php } else { ?>
|
129 |
+
<!-- <?php print_r(array($partnerId, $email, $cryptKey)); ?> -->
|
130 |
+
<iframe style="width: 100%;height: 380px;" id="stats_iframe"
|
131 |
+
data-src="<?php echo statIframe($projectId, $partnerId, $email, $cryptKey); ?>">
|
132 |
+
</iframe> <?php
|
133 |
+
} ?>
|
134 |
+
<button class="reg_btn" type="button">Запросить секретный ключ</button>
|
135 |
+
<br/>
|
136 |
+
|
137 |
+
<div class="reg_block">
|
138 |
+
<label>Email<input type="text" class="uptolike_email"></label><br/>
|
139 |
+
<button type="button" class="button-primary">Отправить ключ на email</button>
|
140 |
+
<br/>
|
141 |
+
</div>
|
142 |
+
<button class="enter_btn" type="button">Авторизация</button>
|
143 |
+
<br/>
|
144 |
+
|
145 |
+
<div class="enter_block">
|
146 |
+
<label>Email<input type="text" class="uptolike_email"></label><br/>
|
147 |
+
<label>Ключ<input type="text" class="id_number"></label><br/>
|
148 |
+
<button type="button" class="button-primary">Сохранить</button>
|
149 |
+
<br/>
|
150 |
+
</div>
|
151 |
+
</div>
|
152 |
+
|
153 |
+
<div class="wrapper-tab " id="con_settings">
|
154 |
+
<?php
|
155 |
+
$my_settings_page = new MySettingsPage();
|
156 |
+
$my_settings_page->page_init();
|
157 |
+
settings_fields('my_option_group');
|
158 |
+
do_settings_sections($my_settings_page->settings_page_name);
|
159 |
+
?>
|
160 |
+
<p>Для вставки шорткода в .php файл шаблона нужно использовать конструкцию <br>
|
161 |
+
<?php echo do_shortcode("[uptolike]"); ?><br>
|
162 |
+
Для вставки в режиме визуального редактора достаточно вставить [uptolike].</p>
|
163 |
+
<input type="submit" name="submit_btn" value="Cохранить изменения">
|
164 |
+
|
165 |
+
<br>
|
166 |
+
"Данный плагин полностью бесплатен. Мы регулярно его улучшаем и добавляем новые функции.<br>
|
167 |
+
Пожалуйста, <a href="https://wordpress.org/support/view/plugin-reviews/uptolike-share">оставьте свой отзыв на данной странице</a>. Спасибо! <br>
|
168 |
+
|
169 |
+
</div>
|
170 |
+
|
171 |
+
|
172 |
+
</form>
|
173 |
+
</div>
|
174 |
+
</div>
|
175 |
+
<?php
|
176 |
+
}
|
177 |
+
|
178 |
+
usb_admin_page();
|
widget_options.php
ADDED
@@ -0,0 +1,851 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
h2.placeholder {
|
121 |
+
font-size: 1px;
|
122 |
+
padding: 1px;
|
123 |
+
margin: 0px;
|
124 |
+
height: 2px;
|
125 |
+
}
|
126 |
+
|
127 |
+
div.wrapper-tab {
|
128 |
+
display: none;
|
129 |
+
}
|
130 |
+
|
131 |
+
div.wrapper-tab.active {
|
132 |
+
display: block;
|
133 |
+
width: 100%;
|
134 |
+
}
|
135 |
+
|
136 |
+
input#id_number {
|
137 |
+
width: 520px;
|
138 |
+
}
|
139 |
+
</style>
|
140 |
+
<div class="wrap">
|
141 |
+
<h2 class="placeholder"> </h2>
|
142 |
+
<div id="wrapper">
|
143 |
+
<form id="settings_form" method="post" action="options.php">
|
144 |
+
<H1> UpToLike виджет</H1>
|
145 |
+
<h2 class="nav-tab-wrapper">
|
146 |
+
<a class="nav-tab nav-tab-active" href="#" id="construct">
|
147 |
+
Конструктор
|
148 |
+
</a>
|
149 |
+
<a class="nav-tab" href="#" id="stat">
|
150 |
+
Статистика
|
151 |
+
</a>
|
152 |
+
|
153 |
+
<a class="nav-tab" href="#" id="settings">
|
154 |
+
Настройки
|
155 |
+
</a>
|
156 |
+
</h2>
|
157 |
+
<div class="wrapper-tab active" id="con_construct">
|
158 |
+
<iframe id='cons_iframe' style='height: 445px;width: 100%;' data-src="<?php echo $this->constructorIframe($projectId, $partnerId, $email, $cryptKey); ?>"></iframe>
|
159 |
+
<br>
|
160 |
+
<a onclick="getCode();" href="#">
|
161 |
+
<button type="reset">Сохранить изменения</button>
|
162 |
+
</a>
|
163 |
+
</div>
|
164 |
+
<div class="wrapper-tab" id="con_stat">
|
165 |
+
<?php if (('' == $partnerId) OR ('' == $email) OR ('' == $cryptKey)) {
|
166 |
+
|
167 |
+
?>
|
168 |
+
<h2>Статистика</h2>
|
169 |
+
<p>Для просмотра статистики необходимо ввести ваш секретный ключ </p>
|
170 |
+
<?php } else { ?>
|
171 |
+
<!-- <?php print_r(array($partnerId,$email, $cryptKey)); ?> -->
|
172 |
+
<iframe style="width: 100%;height: 380px;" id="stats_iframe" data-src="<?php echo $this->statIframe($projectId, $partnerId, $email, $cryptKey); ?>">
|
173 |
+
</iframe> <?php
|
174 |
+
} ?>
|
175 |
+
<button class="reg_btn" type="button">Запросить секретный ключ</button><br/>
|
176 |
+
<div class="reg_block">
|
177 |
+
<label>Email<input type="text" class="uptolike_email"></label><br/>
|
178 |
+
<button type="button" class="button-primary">Отправить ключ на email</button><br/>
|
179 |
+
</div>
|
180 |
+
<button class="enter_btn" type="button">Авторизация</button><br/>
|
181 |
+
<div class="enter_block" >
|
182 |
+
<label>Email<input type="text" class="uptolike_email"></label><br/>
|
183 |
+
<label>Ключ<input type="text" class="id_number"></label><br/>
|
184 |
+
<button type="button" class="button-primary">Сохранить</button><br/>
|
185 |
+
</div>
|
186 |
+
</div>
|
187 |
+
<div class="wrapper-tab" id="con_settings">
|
188 |
+
<?php
|
189 |
+
settings_fields('my_option_group');
|
190 |
+
do_settings_sections($this->settings_page_name);
|
191 |
+
?>
|
192 |
+
<p>Для вставки шорткода в .php файл шаблона нужно использовать конструкцию
|
193 |
+
<?php echo do_shortcode("[uptolike]"); ?<
|
194 |
+
Для вставки в режиме визуального редактора достаточно
|
195 |
+
[uptolike]</p>
|
196 |
+
|
197 |
+
<input type="submit" name="submit_btn" value="Cохранить изменения">
|
198 |
+
<br>
|
199 |
+
"Данный плагин полностью бесплатен. Мы регулярно его улучшаем и добавляем новые функции.<br>
|
200 |
+
Пожалуйста, <a href="https://wordpress.org/support/view/plugin-reviews/uptolike-share">оставьте свой отзыв на данной странице</a>. Спасибо! <br>
|
201 |
+
|
202 |
+
</div>
|
203 |
+
|
204 |
+
</form>
|
205 |
+
</div>
|
206 |
+
</div>
|
207 |
+
<?php
|
208 |
+
}
|
209 |
+
|
210 |
+
public function page_init()
|
211 |
+
{
|
212 |
+
register_setting(
|
213 |
+
'my_option_group', // Option group
|
214 |
+
'my_option_name', // Option name
|
215 |
+
array($this, 'sanitize') // Sanitize
|
216 |
+
);
|
217 |
+
|
218 |
+
add_settings_section(
|
219 |
+
'setting_section_id', // ID
|
220 |
+
'Настройки виджета', // Title
|
221 |
+
array($this, 'print_section_info'), // Callback
|
222 |
+
$this->settings_page_name//'my-setting-admin' // Page
|
223 |
+
);
|
224 |
+
|
225 |
+
add_settings_field(
|
226 |
+
'widget_code', // ID
|
227 |
+
'код виджета', // Title
|
228 |
+
array($this, 'widget_code_callback'), // Callback
|
229 |
+
$this->settings_page_name, //'my-setting-admin', // Page
|
230 |
+
'setting_section_id' // Section
|
231 |
+
);
|
232 |
+
|
233 |
+
add_settings_field(
|
234 |
+
'data_pid', // ID
|
235 |
+
'Ключ(CryptKey)', // Title
|
236 |
+
array($this, 'id_number_callback'), // Callback
|
237 |
+
$this->settings_page_name, //'my-setting-admin', // Page
|
238 |
+
'setting_section_id' // Section
|
239 |
+
);
|
240 |
+
|
241 |
+
add_settings_field(
|
242 |
+
'email', //ID
|
243 |
+
'email для регистрации',
|
244 |
+
array($this, 'uptolike_email_callback'),
|
245 |
+
$this->settings_page_name, //'my-setting-admin',
|
246 |
+
'setting_section_id'
|
247 |
+
);
|
248 |
+
|
249 |
+
add_settings_field(
|
250 |
+
'on_main_static', //ID
|
251 |
+
'Располагать на главной странице в фиксированном блоке',
|
252 |
+
array($this, 'uptolike_on_main_static_callback'),
|
253 |
+
$this->settings_page_name, //'my-setting-admin',
|
254 |
+
'setting_section_id'
|
255 |
+
);
|
256 |
+
|
257 |
+
add_settings_field(
|
258 |
+
'on_main', //ID
|
259 |
+
'Располагать блок на главной странице с материалом',
|
260 |
+
array($this, 'uptolike_on_main_callback'),
|
261 |
+
$this->settings_page_name, //'my-setting-admin',
|
262 |
+
'setting_section_id'
|
263 |
+
);
|
264 |
+
|
265 |
+
add_settings_field(
|
266 |
+
'on_page', //ID
|
267 |
+
'Располагать блок на статических страницах',
|
268 |
+
array($this, 'uptolike_on_page_callback'),
|
269 |
+
$this->settings_page_name, //'my-setting-admin',
|
270 |
+
'setting_section_id'
|
271 |
+
);
|
272 |
+
|
273 |
+
add_settings_field(
|
274 |
+
'on_archive', //ID
|
275 |
+
'Убрать кнопки в анонсах постов',
|
276 |
+
array($this, 'uptolike_on_archive_callback'),
|
277 |
+
$this->settings_page_name, //'my-setting-admin',
|
278 |
+
'setting_section_id'
|
279 |
+
);
|
280 |
+
add_settings_field(
|
281 |
+
'widget_position', //ID
|
282 |
+
'Расположение блока на странице с материалом',
|
283 |
+
array($this, 'uptolike_widget_position_callback'),
|
284 |
+
$this->settings_page_name, //'my-setting-admin',
|
285 |
+
'setting_section_id'
|
286 |
+
);
|
287 |
+
|
288 |
+
add_settings_field(
|
289 |
+
'widget_align', //ID
|
290 |
+
'Тип выравнивания блока с кнопками',
|
291 |
+
array($this, 'uptolike_widget_align_callback'),
|
292 |
+
$this->settings_page_name, //'my-setting-admin',
|
293 |
+
'setting_section_id'
|
294 |
+
);
|
295 |
+
|
296 |
+
add_settings_field(
|
297 |
+
'widget_mode', //ID
|
298 |
+
'Режим работы плагина',
|
299 |
+
array($this, 'uptolike_widget_mode_callback'),
|
300 |
+
$this->settings_page_name, //'my-setting-admin',
|
301 |
+
'setting_section_id'
|
302 |
+
);
|
303 |
+
|
304 |
+
|
305 |
+
add_settings_field(
|
306 |
+
'feedback', //ID
|
307 |
+
'Обратная связь',
|
308 |
+
array($this, 'uptolike_feedback_callback'),
|
309 |
+
$this->settings_page_name, //'my-setting-admin',
|
310 |
+
'setting_section_id'
|
311 |
+
);
|
312 |
+
|
313 |
+
|
314 |
+
add_settings_field(
|
315 |
+
'uptolike_json', //ID
|
316 |
+
'настройки конструктора',
|
317 |
+
array($this, 'uptolike_json_callback'),
|
318 |
+
$this->settings_page_name, //'my-setting-admin',
|
319 |
+
'setting_section_id'
|
320 |
+
);
|
321 |
+
}
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Sanitize each setting field as needed
|
325 |
+
*
|
326 |
+
* @param array $input Contains all settings fields as array keys
|
327 |
+
*/
|
328 |
+
public function sanitize($input)
|
329 |
+
{
|
330 |
+
$new_input = array();
|
331 |
+
if (isset($input['id_number']))
|
332 |
+
$new_input['id_number'] = str_replace(' ','',$input['id_number']);
|
333 |
+
|
334 |
+
if (isset($input['widget_code']))
|
335 |
+
$new_input['widget_code'] = $input['widget_code'];
|
336 |
+
|
337 |
+
if (isset($input['uptolike_email']))
|
338 |
+
$new_input['uptolike_email'] = $input['uptolike_email'];
|
339 |
+
|
340 |
+
if (isset($input['before_content']))
|
341 |
+
$new_input['before_content'] = $input['before_content'];
|
342 |
+
|
343 |
+
if (isset($input['on_main_static'])) {
|
344 |
+
$new_input['on_main_static'] = 1;
|
345 |
+
} else $new_input['on_main_static'] = 0;
|
346 |
+
|
347 |
+
if (isset($input['on_main'])) {
|
348 |
+
$new_input['on_main'] = 1;
|
349 |
+
} else $new_input['on_main'] = 0;
|
350 |
+
|
351 |
+
if (isset($input['on_page'])) {
|
352 |
+
$new_input['on_page'] = 1;
|
353 |
+
} else $new_input['on_page'] = 0;
|
354 |
+
|
355 |
+
if (isset($input['on_archive'])) {
|
356 |
+
$new_input['on_archive'] = 1;
|
357 |
+
} else $new_input['on_archive'] = 0;
|
358 |
+
|
359 |
+
if (isset($input['email']))
|
360 |
+
$new_input['email'] = $input['email'];
|
361 |
+
|
362 |
+
if (isset($input['after_content']))
|
363 |
+
$new_input['after_content'] = $input['after_content'];
|
364 |
+
|
365 |
+
if (isset($input['widget_position']))
|
366 |
+
$new_input['widget_position'] = $input['widget_position'];
|
367 |
+
|
368 |
+
if (isset($input['widget_mode']))
|
369 |
+
$new_input['widget_mode'] = $input['widget_mode'];
|
370 |
+
|
371 |
+
if (isset($input['widget_align']))
|
372 |
+
$new_input['widget_align'] = $input['widget_align'];
|
373 |
+
|
374 |
+
|
375 |
+
if (isset($input['uptolike_json']))
|
376 |
+
$new_input['uptolike_json'] = $input['uptolike_json'];
|
377 |
+
|
378 |
+
return $new_input;
|
379 |
+
}
|
380 |
+
|
381 |
+
|
382 |
+
public function print_section_info()
|
383 |
+
{
|
384 |
+
//print 'Enter your settings below:';
|
385 |
+
}
|
386 |
+
|
387 |
+
public function widget_code_callback()
|
388 |
+
{
|
389 |
+
printf(
|
390 |
+
'<textarea id="widget_code" name="my_option_name[widget_code]" >%s</textarea>',
|
391 |
+
isset($this->options['widget_code']) ? esc_attr($this->options['widget_code']) : ''
|
392 |
+
);
|
393 |
+
}
|
394 |
+
|
395 |
+
/** 12536473050877
|
396 |
+
* Get the settings option array and print one of its values
|
397 |
+
*/
|
398 |
+
public function id_number_callback()
|
399 |
+
{
|
400 |
+
printf(
|
401 |
+
'<input type="text" class="id_number" name="my_option_name[id_number]" value="%s" />',
|
402 |
+
isset($this->options['id_number']) ? esc_attr($this->options['id_number']) : ''
|
403 |
+
);
|
404 |
+
}
|
405 |
+
|
406 |
+
public function uptolike_email_callback()
|
407 |
+
{
|
408 |
+
printf(
|
409 |
+
'<input type="text" id="uptolike_email" name="my_option_name[uptolike_email]" value="%s" />',
|
410 |
+
isset($this->options['uptolike_email']) ? esc_attr($this->options['uptolike_email']) : get_option('admin_email')
|
411 |
+
);
|
412 |
+
}
|
413 |
+
|
414 |
+
public function uptolike_json_callback()
|
415 |
+
{
|
416 |
+
printf(
|
417 |
+
'<input type="hidden" id="uptolike_json" name="my_option_name[uptolike_json]" value="%s" />',
|
418 |
+
isset($this->options['uptolike_json']) ? esc_attr($this->options['uptolike_json']) : ''
|
419 |
+
);
|
420 |
+
}
|
421 |
+
|
422 |
+
public function uptolike_partner_id_callback()
|
423 |
+
{
|
424 |
+
printf(
|
425 |
+
'<input type="text" id="uptolike_partner" name="my_option_name[uptolike_partner]" value="%s" />',
|
426 |
+
isset($this->options['uptolike_partner']) ? esc_attr($this->options['uptolike_partner']) : ''
|
427 |
+
);
|
428 |
+
}
|
429 |
+
|
430 |
+
public function uptolike_feedback_callback()
|
431 |
+
{
|
432 |
+
echo '<a href="mailto:support@uptolike.com" target="_top"> support@uptolike.com</a>';
|
433 |
+
}
|
434 |
+
|
435 |
+
public function uptolike_project_callback()
|
436 |
+
{
|
437 |
+
printf(
|
438 |
+
'<input type="text" id="uptolike_project" name="my_option_name[uptolike_project]" value="%s" />',
|
439 |
+
isset($this->options['uptolike_project']) ? esc_attr($this->options['uptolike_project']) : ''
|
440 |
+
);
|
441 |
+
}
|
442 |
+
|
443 |
+
public function uptolike_on_main_static_callback()
|
444 |
+
{
|
445 |
+
echo '<input type="checkbox" id="on_main_static" name="my_option_name[on_main_static]"';
|
446 |
+
echo ($this->options['on_main_static'] == '1' ? 'checked="checked"' : ''); echo ' />';
|
447 |
+
|
448 |
+
}
|
449 |
+
|
450 |
+
public function uptolike_on_main_callback()
|
451 |
+
{
|
452 |
+
echo '<input type="checkbox" id="on_main" name="my_option_name[on_main]"';
|
453 |
+
echo ($this->options['on_main'] == '1' ? 'checked="checked"' : ''); echo ' />';
|
454 |
+
|
455 |
+
}
|
456 |
+
public function uptolike_on_page_callback()
|
457 |
+
{
|
458 |
+
echo '<input type="checkbox" id="on_page" name="my_option_name[on_page]"';
|
459 |
+
echo ($this->options['on_page'] == '1' ? 'checked="checked"' : ''); echo ' />';
|
460 |
+
|
461 |
+
}
|
462 |
+
public function uptolike_on_archive_callback()
|
463 |
+
{
|
464 |
+
echo '<input type="checkbox" id="on_archive" name="my_option_name[on_archive]"';
|
465 |
+
echo ($this->options['on_archive'] == '1' ? 'checked="checked"' : ''); echo ' />';
|
466 |
+
|
467 |
+
}
|
468 |
+
|
469 |
+
public function uptolike_widget_mode_callback()
|
470 |
+
{
|
471 |
+
$plg_mode = $code_mode = $both_mode = $default = '';
|
472 |
+
|
473 |
+
if (isset($this->options['widget_mode'])) {
|
474 |
+
if ('plg' == $this->options['widget_mode']) {
|
475 |
+
$plg_mode = "selected='selected'";
|
476 |
+
} elseif ('code' == $this->options['widget_mode']) {
|
477 |
+
$code_mode = "selected='selected'";
|
478 |
+
} elseif ('both' == $this->options['widget_mode']) {
|
479 |
+
$both_mode = "selected='selected'";
|
480 |
+
}
|
481 |
+
} else {
|
482 |
+
$my_options = get_option('my_option_name');
|
483 |
+
$my_options['widget_mode'] = 'plg'; // cryptkey store
|
484 |
+
update_option('my_option_name', $my_options);
|
485 |
+
}
|
486 |
+
//$default = "selected='selected'";
|
487 |
+
echo "<select id='widget_mode' name='my_option_name[widget_mode]'>
|
488 |
+
<option {$plg_mode} value='plg'>Плагин</option>
|
489 |
+
<option {$code_mode} value='code'>Шорткод</option>
|
490 |
+
<option {$both_mode} value='both'>Плагин и шорткод</option>
|
491 |
+
</select>";
|
492 |
+
|
493 |
+
}
|
494 |
+
|
495 |
+
public function uptolike_widget_align_callback()
|
496 |
+
{
|
497 |
+
$left = $right = $center = $default = '';
|
498 |
+
|
499 |
+
if (isset($this->options['widget_align'])) {
|
500 |
+
if ('left' == $this->options['widget_align']) {
|
501 |
+
$left = "selected='selected'";
|
502 |
+
} elseif ('right' == $this->options['widget_align']) {
|
503 |
+
$right = "selected='selected'";
|
504 |
+
} elseif ('center' == $this->options['widget_align']) {
|
505 |
+
$center = "selected='selected'";
|
506 |
+
}
|
507 |
+
} else {
|
508 |
+
$my_options = get_option('my_option_name');
|
509 |
+
$my_options['widget_align'] = 'left'; // cryptkey store
|
510 |
+
update_option('my_option_name', $my_options);
|
511 |
+
}
|
512 |
+
//$default = "selected='selected'";
|
513 |
+
echo "<select id='widget_align' name='my_option_name[widget_align]'>
|
514 |
+
<option {$left} value='left'>По левому краю</option>
|
515 |
+
<option {$right} value='right'>По правому краю</option>
|
516 |
+
<option {$center} value='center'>По центру</option>
|
517 |
+
</select>";
|
518 |
+
|
519 |
+
}
|
520 |
+
|
521 |
+
public function uptolike_widget_position_callback()
|
522 |
+
{
|
523 |
+
$top = $bottom = $both = $default = '';
|
524 |
+
|
525 |
+
if (isset($this->options['widget_position'])) {
|
526 |
+
if ('top' == $this->options['widget_position']) {
|
527 |
+
$top = "selected='selected'";
|
528 |
+
} elseif ('bottom' == $this->options['widget_position']) {
|
529 |
+
$bottom = "selected='selected'";
|
530 |
+
} elseif ('both' == $this->options['widget_position']) {
|
531 |
+
$both = "selected='selected'";
|
532 |
+
} else {
|
533 |
+
$bottom = "selected='selected'";
|
534 |
+
}
|
535 |
+
} else {
|
536 |
+
$my_options = get_option('my_option_name');
|
537 |
+
$my_options['widget_position'] = 'bottom'; // cryptkey store
|
538 |
+
update_option('my_option_name', $my_options);
|
539 |
+
}
|
540 |
+
$default = "selected='selected'";
|
541 |
+
echo "<select id='widget_position' name='my_option_name[widget_position]'>
|
542 |
+
<option {$top} value='top'>Только сверху</option>
|
543 |
+
<option {$bottom} value='bottom'>Только снизу</option>
|
544 |
+
<option {$both} value='both'>Сверху и снизу</option>
|
545 |
+
</select>";
|
546 |
+
|
547 |
+
}
|
548 |
+
|
549 |
+
}
|
550 |
+
|
551 |
+
function get_widget_code() {
|
552 |
+
$options = get_option('my_option_name');
|
553 |
+
$widget_code = $options['widget_code'];
|
554 |
+
$url = get_permalink();
|
555 |
+
$domain = preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
|
556 |
+
$domain = str_replace('-','',$domain);
|
557 |
+
$data_pid = 'cms' . str_replace('.', '', $domain);
|
558 |
+
|
559 |
+
$widget_code = str_replace('data-pid="-1"','data-pid="' . $data_pid . '"',$widget_code);
|
560 |
+
$widget_code = str_replace('data-pid=""','data-pid="' . $data_pid . '"',$widget_code);
|
561 |
+
$widget_code = str_replace('div data', 'div data-url="' . $url . '" data', $widget_code);
|
562 |
+
$align = $options['widget_align'];//'left';//'right', 'center';
|
563 |
+
// var_dump($widget_code);
|
564 |
+
$align_style = 'style=" text-align: '.$align.';"';
|
565 |
+
$widget_code = str_replace('<div ', '<div '.$align_style.' ', $widget_code);
|
566 |
+
|
567 |
+
return $widget_code;
|
568 |
+
|
569 |
+
}
|
570 |
+
|
571 |
+
function add_widget($content)
|
572 |
+
{
|
573 |
+
//print_r($options = get_option('my_option_name'));
|
574 |
+
//return $content;
|
575 |
+
|
576 |
+
$options = get_option('my_option_name');
|
577 |
+
|
578 |
+
// $options = get_option('my_option_name');
|
579 |
+
$widget_mode = $options['widget_mode'];
|
580 |
+
|
581 |
+
|
582 |
+
if (is_array($options) && (($widget_mode == 'plg') or ($widget_mode == 'both')) && array_key_exists('widget_code', $options)) {
|
583 |
+
|
584 |
+
//$widget_code_before = $widget_code_after = '';
|
585 |
+
$widget_code = get_widget_code();
|
586 |
+
|
587 |
+
if (is_page()) {//это страница
|
588 |
+
if ($options['on_page'] == 1) {
|
589 |
+
switch ($options['widget_position']) {
|
590 |
+
case 'both':
|
591 |
+
return $widget_code.$content.$widget_code;
|
592 |
+
case 'top':
|
593 |
+
return $widget_code.$content;
|
594 |
+
case 'bottom':
|
595 |
+
return $content.$widget_code;
|
596 |
+
}
|
597 |
+
} else return $content;
|
598 |
+
} elseif (is_archive()) {
|
599 |
+
if ($options['on_archive'] == 0) {
|
600 |
+
switch ($options['widget_position']) {
|
601 |
+
case 'both':
|
602 |
+
return $widget_code.$content.$widget_code;
|
603 |
+
case 'top':
|
604 |
+
return $widget_code.$content;
|
605 |
+
case 'bottom':
|
606 |
+
return $content.$widget_code;
|
607 |
+
}
|
608 |
+
} else return $content;
|
609 |
+
} elseif (is_front_page()) {
|
610 |
+
if ($options['on_main'] == 1) {
|
611 |
+
switch ($options['widget_position']) {
|
612 |
+
case 'both':
|
613 |
+
return $widget_code.$content.$widget_code;
|
614 |
+
case 'top':
|
615 |
+
return $widget_code.$content;
|
616 |
+
case 'bottom':
|
617 |
+
return $content.$widget_code;
|
618 |
+
}
|
619 |
+
} else return $content;
|
620 |
+
} else {
|
621 |
+
switch ($options['widget_position']) {
|
622 |
+
case 'both':
|
623 |
+
return $widget_code.$content.$widget_code;
|
624 |
+
case 'top':
|
625 |
+
return $widget_code.$content;
|
626 |
+
case 'bottom':
|
627 |
+
return $content.$widget_code;
|
628 |
+
}
|
629 |
+
};
|
630 |
+
|
631 |
+
} else {
|
632 |
+
return $content;
|
633 |
+
}
|
634 |
+
}
|
635 |
+
|
636 |
+
add_filter('the_content', 'add_widget', 100);
|
637 |
+
|
638 |
+
|
639 |
+
function uptolike_shortcode( $atts ){
|
640 |
+
|
641 |
+
$options = get_option('my_option_name');
|
642 |
+
$widget_mode = $options['widget_mode'];
|
643 |
+
if(($widget_mode == 'code') or ($widget_mode == 'both')) {
|
644 |
+
return get_widget_code();
|
645 |
+
};
|
646 |
+
|
647 |
+
|
648 |
+
|
649 |
+
//return add_widget("");
|
650 |
+
}
|
651 |
+
add_shortcode( 'uptolike', 'uptolike_shortcode' );
|
652 |
+
|
653 |
+
function my_widgetcode_notice()
|
654 |
+
{
|
655 |
+
$options = get_option('my_option_name');
|
656 |
+
if (is_array($options) && array_key_exists('widget_code', $options)) {
|
657 |
+
$widget_code = $options['widget_code'];
|
658 |
+
if ('' == $widget_code) {
|
659 |
+
echo " <div class='updated'>
|
660 |
+
<p>В настройках UpToLike 'Конструктор' выберите тип виджета и нажмите 'Сохранить'</p>
|
661 |
+
</div>";
|
662 |
+
}
|
663 |
+
};
|
664 |
+
}
|
665 |
+
|
666 |
+
function logger($str)
|
667 |
+
{
|
668 |
+
file_put_contents(WP_PLUGIN_DIR . '/uptolike/log.txt', date(DATE_RFC822) . $str . PHP_EOL, FILE_APPEND | LOCK_EX);
|
669 |
+
}
|
670 |
+
|
671 |
+
function try_reg()
|
672 |
+
{
|
673 |
+
include('api_functions.php');
|
674 |
+
$domain = preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
|
675 |
+
$options = get_option('my_option_name');
|
676 |
+
$email = $options['uptolike_email'];
|
677 |
+
if ('' == $options['id_number']) {
|
678 |
+
$reg_ans = userReg($email, 'cms', 'cms' . $domain);
|
679 |
+
if (is_string($reg_ans)) {
|
680 |
+
$my_options = get_option('my_option_name');
|
681 |
+
$my_options['id_number'] = $reg_ans; // cryptkey store
|
682 |
+
$my_options['choice'] = 'reg';
|
683 |
+
update_option('my_option_name', $my_options);
|
684 |
+
};
|
685 |
+
update_option('reg_try', true);
|
686 |
+
}
|
687 |
+
}
|
688 |
+
|
689 |
+
function my_choice_notice()
|
690 |
+
{
|
691 |
+
$options = get_option('my_option_name');
|
692 |
+
if (is_bool($options) or (('' == $options['id_number']) and ((!array_key_exists('choice', $options)) OR ('ignore' !== $options['choice'])))) {
|
693 |
+
echo "<div class='updated'>
|
694 |
+
<div><img style='
|
695 |
+
float: left;
|
696 |
+
height: 38px;
|
697 |
+
margin-left: -9px;
|
698 |
+
margin-right: 5px;
|
699 |
+
' src='//uptolike.ru/img/logo.png'>
|
700 |
+
</div>
|
701 |
+
Кнопки успешно установлены! <br>Для просмотра статистики необходимо:
|
702 |
+
<a href='options-general.php?page=uptolike_settings#enter'>Ввести полученный ключ</a>
|
703 |
+
| <a href='options-general.php?page=uptolike_settings#reg'>Запросить ключ</a>
|
704 |
+
| <a href='options-general.php?page=uptolike_settings&choice=ignore'>Скрыть</a> </div>";
|
705 |
+
|
706 |
+
|
707 |
+
};
|
708 |
+
}
|
709 |
+
|
710 |
+
function set_default_code()
|
711 |
+
{
|
712 |
+
$options = get_option('my_option_name');
|
713 |
+
if (is_bool($options)) {
|
714 |
+
$options = array();
|
715 |
+
}
|
716 |
+
$data_url = 'cms' . $_SERVER['HTTP_HOST'];
|
717 |
+
$data_pid = 'cms' . str_replace('.', '', preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']));
|
718 |
+
$code = <<<EOD
|
719 |
+
<script type="text/javascript">(function (w, doc) {
|
720 |
+
if (!w.__utlWdgt) {
|
721 |
+
w.__utlWdgt = true;
|
722 |
+
var d = doc, s = d.createElement('script'), g = 'getElementsByTagName';
|
723 |
+
s.type = 'text/javascript';
|
724 |
+
s.charset = 'UTF-8';
|
725 |
+
s.async = true;
|
726 |
+
s.src = ('https:' == w.location.protocol ? 'https' : 'http') + '://w.uptolike.com/widgets/v1/uptolike.js';
|
727 |
+
var h = d[g]('body')[0];
|
728 |
+
h.appendChild(s);
|
729 |
+
}
|
730 |
+
})(window, document);
|
731 |
+
</script>
|
732 |
+
<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">
|
733 |
+
</div>
|
734 |
+
EOD;
|
735 |
+
|
736 |
+
$code = str_replace('data-pid', 'data-pid="' . $data_pid . '"', $code);
|
737 |
+
|
738 |
+
$code = str_replace('data-url', 'data-url="' . $data_url . '"', $code);
|
739 |
+
$options['widget_code'] = $code;
|
740 |
+
$options['on_main_static'] = 1;
|
741 |
+
$options['on_main'] = 1;
|
742 |
+
$options['on_page'] = 0;
|
743 |
+
$options['on_archive'] = 1;
|
744 |
+
$options['widget_position'] = 'bottom';
|
745 |
+
$options['widget_align'] = 'left';
|
746 |
+
|
747 |
+
|
748 |
+
update_option('my_option_name', $options);
|
749 |
+
}
|
750 |
+
|
751 |
+
function choice_helper($choice)
|
752 |
+
{
|
753 |
+
$options = get_option('my_option_name');
|
754 |
+
$options['choice'] = $choice;
|
755 |
+
if ('ignore' == $choice) {
|
756 |
+
set_default_code();
|
757 |
+
}
|
758 |
+
update_option('my_option_name', $options);
|
759 |
+
}
|
760 |
+
|
761 |
+
|
762 |
+
|
763 |
+
function usb_admin_actions()
|
764 |
+
{
|
765 |
+
|
766 |
+
if ( current_user_can('manage_options') ) {
|
767 |
+
if (function_exists('add_meta_box')) {
|
768 |
+
|
769 |
+
add_menu_page("UpToLike", "UpToLike", "manage_options", "UpToLike", 'my_custom_menu_page', plugins_url('uptolike-share/logo-small.png'));
|
770 |
+
}
|
771 |
+
|
772 |
+
|
773 |
+
}
|
774 |
+
}
|
775 |
+
|
776 |
+
function my_custom_menu_page(){
|
777 |
+
include_once( 'usb-admin.php' );
|
778 |
+
}
|
779 |
+
|
780 |
+
function headeruptolike(){
|
781 |
+
$options = get_option('my_option_name');
|
782 |
+
if (!(is_bool($options))){
|
783 |
+
if ($options['on_main_static'] == 1) {
|
784 |
+
echo get_widget_code();
|
785 |
+
}
|
786 |
+
}
|
787 |
+
|
788 |
+
|
789 |
+
}
|
790 |
+
|
791 |
+
class UptolikeWidget extends WP_Widget {
|
792 |
+
|
793 |
+
function UptolikeWidget() {
|
794 |
+
// Instantiate the parent object
|
795 |
+
parent::__construct( false, 'Блок кнопок UpToLike' );
|
796 |
+
}
|
797 |
+
|
798 |
+
function widget( $args, $instance ) {
|
799 |
+
echo get_widget_code();
|
800 |
+
//echo 'uptolike widget';
|
801 |
+
// Widget outputo
|
802 |
+
}
|
803 |
+
|
804 |
+
function update( $new_instance, $old_instance ) {
|
805 |
+
// Save widget options
|
806 |
+
}
|
807 |
+
|
808 |
+
function form( $instance ) {
|
809 |
+
// Output admin widget options form
|
810 |
+
}
|
811 |
+
}
|
812 |
+
|
813 |
+
function uptolike_register_widgets() {
|
814 |
+
register_widget( 'UptolikeWidget' );
|
815 |
+
}
|
816 |
+
|
817 |
+
|
818 |
+
|
819 |
+
register_activation_hook(__FILE__,'usb_admin_actions');
|
820 |
+
register_deactivation_hook(__FILE__,'usb_admin_actions_remove');
|
821 |
+
|
822 |
+
add_action( 'widgets_init', 'uptolike_register_widgets' );
|
823 |
+
|
824 |
+
add_action('wp_footer', 'headeruptolike', 1);
|
825 |
+
|
826 |
+
|
827 |
+
|
828 |
+
add_action('admin_notices', 'my_choice_notice');
|
829 |
+
add_action('admin_notices', 'my_widgetcode_notice');
|
830 |
+
add_action('admin_menu', 'usb_admin_actions');
|
831 |
+
|
832 |
+
|
833 |
+
|
834 |
+
$options = get_option('my_option_name');
|
835 |
+
|
836 |
+
if (is_admin()) {
|
837 |
+
$options = get_option('my_option_name');
|
838 |
+
|
839 |
+
if (array_key_exists('regme', $_REQUEST)) {
|
840 |
+
try_reg();
|
841 |
+
}
|
842 |
+
if (array_key_exists('choice', $_REQUEST)) {
|
843 |
+
choice_helper($_REQUEST['choice']);
|
844 |
+
}
|
845 |
+
|
846 |
+
$my_settings_page = new MySettingsPage();
|
847 |
+
if (is_bool($options) OR (!array_key_exists('widget_code', $options)) OR ('' == $options['widget_code'])) {
|
848 |
+
set_default_code();
|
849 |
+
}
|
850 |
+
|
851 |
+
}
|