PluginProbe ʕ •ᴥ•ʔ
Wp Social Login and Register Social Counter / 2.2.4
Wp Social Login and Register Social Counter v2.2.4
trunk 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.10 1.3.11 1.3.2 1.3.3 1.3.4 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.4 1.4.5 1.4.6 1.4.8 1.4.9 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.8 2.2.9 3.0.0 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0
wp-social / template / admin / counter / providers-counter.php
wp-social / template / admin / counter Last commit date
_instagram__modal_content.php 5 years ago counter-setting.php 3 years ago providers-counter.php 3 years ago style-setting.php 3 years ago tab-menu.php 3 years ago
providers-counter.php
560 lines
1 <?php
2 defined('ABSPATH') || exit;
3 ?>
4
5 <div class="wslu-social-login-main-wrapper">
6 <?php
7
8 require(__DIR__ . '/tab-menu.php');
9
10 /**
11 * todo - check this notice box too : WP1-217
12 * make a function and call it here
13 *
14 */
15
16 if($message_provider == 'show') { ?>
17 <div class="admin-page-framework-admin-notice-animation-container">
18 <div id="XS_Social_Login_Settings"
19 class="updated admin-page-framework-settings-notice-message admin-page-framework-settings-notice-container notice is-dismissible"
20 style="margin: 1em 0; visibility: visible; opacity: 1;">
21 <p><?php echo esc_html__('Providers data have been updated.', 'wp-social'); ?></p>
22 <button type="button" class="notice-dismiss">
23 <span class="screen-reader-text"><?php echo esc_html__('Dismiss this notice.', 'wp-social'); ?></span>
24 </button>
25 </div>
26 </div>
27 <?php } ?>
28
29 <form action="<?php echo esc_url(admin_url() . 'admin.php?page=wslu_counter_setting&tab=wslu_providers'); ?>"
30 name="xs_provider_submit_form"
31 method="post"
32 id="xs_provider_form">
33
34 <div class="xs-social-block-wraper">
35 <ul class="xs-social-block" data-action="sort_providers_counter"
36 data-sort_url="<?php echo esc_url(admin_url() . 'admin-ajax.php'); ?>">
37 <?php
38 $m = 1;
39 $counter = new \WP_Social\Inc\Counter(false);
40 $filed = $counter->xs_counter_providers_data();
41
42 foreach($core_provider as $k => $v) :
43 $name = isset($v['label']) ? $v['label'] : ucfirst($k);
44
45 $js_target_id = 'open_counter__' . $k . '__' . $m;
46
47 ?>
48 <li data-provider="<?php echo esc_attr($k) ?>">
49 <div class="xs-single-social-block <?php echo esc_attr($k); ?>">
50
51 <div class="xs-block-header"
52 onclick="xs_counter_open(this);"
53 xs-target-id="<?php echo esc_attr($js_target_id); ?>">
54 <div class="xs-social-icon">
55 <span class="met-social met-social-<?php echo esc_attr($k); ?>"></span>
56 </div>
57 <h2 class="xs-social-icon-title"><?php echo esc_html__($name, 'wp-social'); ?></h2>
58 </div>
59
60 <div class="xs-block-footer">
61 <div class="left-content">
62 <div class="configure">
63
64 <div class="wslu-single-popup-item wslu-inline">
65
66 <input class="social_switch_button"
67 onchange="social_counter_enable(this)"
68 data-key="<?php echo esc_attr($k); ?>"
69 type="checkbox"
70 id="<?php echo esc_attr($k); ?>_enable"
71 name="xs_counter[social][<?php echo esc_attr($k); ?>][enable]"
72 value="1"
73 <?php echo esc_attr(empty($enabled_providers[$k]['enable']) ? '' : 'checked'); ?> />
74
75 <label for="<?php echo esc_attr($k); ?>_enable"
76 class="social_switch_button_label"></label>
77 </div>
78
79 </div>
80 </div>
81 <div class="right-content">
82 <a href="javascript:void()"
83 class="wslu-social-provider-btn xs-btn btn-special small"
84 onclick="xs_counter_open(this);"
85 xs-target-id="<?php echo esc_attr($js_target_id); ?>">
86
87 <?php
88
89 if(!empty($enabled_providers[$k]['enable'])) {
90 echo esc_html__('Settings', 'wp-social'); ?><?php
91 } else {
92 echo esc_html__('Getting Started', 'wp-social');
93 }
94
95 ?>
96 </a>
97 </div>
98 </div>
99 </div>
100 </li>
101 <?php
102
103 $m++;
104 endforeach; ?>
105 </ul>
106 </div>
107
108 <div class="xs-social-block-wraper-counter">
109 <?php
110 $m = 1;
111
112 $factory = new \WP_Social\Lib\Provider\Counter_Factory();
113
114 foreach($core_provider as $k => $val) :
115
116 $js_target_id = 'open_counter__' . $k . '__' . $m;
117
118 $v = $counter_provider[$k]; // why this bujruki!? cause i do not have time :P
119
120 $obj = $factory->make($k);
121
122 $name = isset($v['label']) ? $v['label'] : '';
123
124 $setLabel = (isset($counter_provider[$k]['label']) && strlen($counter_provider[$k]['label']) > 2) ? $counter_provider[$k]['label'] : $name;
125
126 $defaultText = isset($v['data']['text']) ? $v['data']['text'] : '';
127 $belowText = (isset($counter_provider[$k]['data']['text'])) ? $counter_provider[$k]['data']['text'] : $defaultText;
128 $belowValue = (isset($counter_provider[$k]['data']['value']) && $counter_provider[$k]['data']['value'] > 0) ? $counter_provider[$k]['data']['value'] : 0;
129
130 $filedData = isset($filed[$k]) ? $filed[$k] : '';
131 if(strlen($name) > 2) {
132 ?>
133 <div class="xs-modal-dialog <?php echo esc_attr(($getType == $k) ? 'is-open' : ''); ?>"
134 id="<?php echo esc_attr($js_target_id); ?>">
135 <div class="xs-modal-content">
136
137 <div class="xs-modal-header clear-both">
138
139 <div class="tabHeader">
140 <ul class="tab__list clear-both"></ul>
141 </div>
142 <button
143 type="button"
144 class="xs-btn"
145 onclick="xs_counter_open(this);"
146 xs-target-id="<?php echo esc_attr($js_target_id); ?>">
147 <span class="wslu-icon met-social met-social-cross"></span>
148 </button>
149 </div>
150
151 <div class="xs-modal-body">
152 <div class="ekit--tab__post__details tabContent">
153 <h6 class="wslu-popup-provider-title"><?php echo esc_html__($setLabel, 'wp-social'); ?></h6>
154
155 <div class="wslu-popup-data"> <?php
156
157 if(is_array($filedData)) {
158
159 $fl_nm = __DIR__. '_'.$k.'__modal_content.php';
160
161 foreach($filedData as $fk => $fv) {
162
163 $label_field = isset($fv['label']) ? $fv['label'] : 'Id';
164
165 $input = isset($fv['input']) ? $fv['input'] : 'text';
166 $type = isset($fv['type']) ? $fv['type'] : 'normal';
167
168 $setId = (isset($counter_provider[$k][$fk]) && strlen($counter_provider[$k][$fk]) > 2) ? $counter_provider[$k][$fk] : '';
169
170 $show_access_token_grabbed_msg = false;
171
172 ?>
173
174 <div class="wslu-single-popup-item <?php echo esc_attr(($type == 'access') ? 'xs-access-button-inline' : ''); ?>">
175
176 <?php
177
178 if($input == 'link') { ?>
179
180 <div class="wslu-admin-accordion-btn-group">
181 <a href="<?php echo esc_url($fv['url']) ?>" class="<?php echo esc_attr($fv['class']) ?>" target="_blank">
182 <?php echo esc_html($fv['label']) ?>
183 </a>
184 </div>
185
186 <?php
187
188 } else {
189
190 ?>
191
192 <div class="setting-label-wraper">
193 <label class="setting-label wslu-sec-title"
194 for="xs_<?php echo esc_attr($k); ?>_<?php echo esc_attr($fk); ?>"> <?php echo esc_html__($label_field, 'wp-social'); ?> </label>
195 </div>
196
197 <?php
198
199
200 if($input == 'text') {
201
202 ?>
203
204 <input name="xs_counter[social][<?php echo esc_attr($k); ?>][<?php echo esc_attr($fk); ?>]"
205 style="<?php echo esc_attr(($type == 'access') ? 'cursor: no-drop; opacity: .4;' : ''); ?>"
206 type="text" id="xs_<?php echo esc_attr($k); ?>_<?php echo esc_attr($fk); ?>"
207 value="<?php echo esc_html($setId); ?>"
208 class="wslu-global-input">
209
210 <?php
211
212 if($type == 'access') {
213 echo wp_kses('<button class="xs-btn btn-special small" data-type="modal-trigger" data-target="example-modal-' . $k . '">'.__("Get Access Token", "wp-social").'</button>', \WP_Social\Helper\Helper::get_kses_array());
214 }
215
216 if($show_access_token_grabbed_msg === true) {
217
218
219 $div_id = 'asd_' . time();
220
221
222 echo wp_kses('<div id="' . $div_id . '" style="padding:5px; color:green">Access token grabbed successfully, please save the changes.</div>', \WP_Social\Helper\Helper::get_kses_array());
223
224
225 ?> <script>
226 setTimeout(function () {
227 jQuery('#<?php echo esc_attr($div_id) ?>').slideUp(1000, hide_the_message);
228 }, 5000);
229
230 function hide_the_message() {
231 jQuery('#<?php echo esc_attr($div_id) ?>').remove();
232 }
233
234 </script>
235
236 <?php
237
238 }
239
240 } elseif($input == 'select') {
241
242 $dataSelect = isset($fv['data']) ? $fv['data'] : '';
243
244 if(is_array($dataSelect)) {
245
246 ?>
247
248 <select class="wslu-global-input"
249 name="xs_counter[social][<?php echo esc_attr($k); ?>][<?php echo esc_attr($fk); ?>]"
250 id="xs_<?php echo esc_attr($k); ?>_<?php echo esc_attr($fk); ?>">
251 <?php foreach($dataSelect as $dk => $dv) : ?>
252 <option value="<?php echo esc_attr($dk); ?>" <?php echo esc_attr(($setId == $dk) ? 'selected' : ''); ?>><?php echo esc_html($dv); ?> </option>
253 <?php endforeach; ?>
254 </select>
255 <?php
256
257 }
258
259 }
260
261 }
262
263 ?>
264
265 </div>
266
267 <?php
268
269 if($type == 'access' && $k == $getType) {
270 $setId = get_option('xs_counter_' . $k . '_token') ? get_option('xs_counter_' . $k . '_token') : '';
271
272 if($getType == 'linkedin') {
273
274 $code = isset($_GET['code']) ? sanitize_text_field($_GET['code']) : '';
275 if(strlen($code) > 0) {
276 $cur_page = admin_url() . 'admin.php?page=wslu_counter_setting&tab=wslu_providers&xs_access=' . $k . '';
277
278 $credentials = get_transient('xs_counter_' . $k . '_api_key') . ':' . get_transient('xs_counter_' . $k . '_secret_key');
279 $toSend = base64_encode($credentials);
280
281 $args = [
282 'method' => 'POST',
283 'httpversion' => '1.1',
284 'blocking' => true,
285 'headers' => [
286 'Authorization' => 'Basic ' . $toSend,
287 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8',
288 ],
289 'body' => ['grant_type' => 'authorization_code',
290 'code' => $code,
291 'client_id' => get_transient('xs_counter_' . $k . '_api_key'),
292 'client_secret' => get_transient('xs_counter_' . $k . '_secret_key'),
293 'redirect_uri' => $cur_page,
294 ],
295 ];
296
297 add_filter('https_ssl_verify', '__return_false');
298 $response = wp_remote_post('https://www.linkedin.com/oauth/v2/accessToken', $args);
299
300 $keys = json_decode(wp_remote_retrieve_body($response));
301
302 if(isset($keys->access_token)) {
303 $setId = $keys->access_token;
304 update_option('xs_counter_' . $k . '_token', $setId);
305 update_option('xs_counter_' . $k . '_app_id', get_transient('xs_counter_' . $k . '_api_key'));
306 update_option('xs_counter_' . $k . '_app_secret', get_transient('xs_counter_' . $k . '_secret_key'));
307 }
308 }
309 } elseif($getType == 'dribbble') {
310
311 if(!empty($_GET['code'])) {
312
313 $code = sanitize_text_field($_GET['code']);
314 $cur_page = admin_url() . 'admin.php?page=wslu_counter_setting&tab=wslu_providers&xs_access=' . $k . '';
315
316 /**
317 * As we have received temporary code
318 * now request for access_token via post method
319 * Right now I could not find any documentation
320 * of how long the access token will live in dribbble api document!
321 *
322 * todo - check deeply of token life time and implement refresh access token strategy
323 */
324
325 $args = [
326 'method' => 'POST',
327 'httpversion' => '1.1',
328 'blocking' => true,
329 'body' => [
330 'code' => $code,
331 'client_id' => get_option('xs_counter_dribbble_app_id'),
332 'client_secret' => get_option('xs_counter_dribbble_app_secret'),
333 'redirect_uri' => $cur_page,
334 ],
335 ];
336
337 $response = wp_remote_post('https://dribbble.com/oauth/token', $args);
338 $token = json_decode(wp_remote_retrieve_body($response));
339
340 if(empty($token->error)) {
341 $setId = $token->access_token;
342 $created = $token->created_at;
343 $show_access_token_grabbed_msg = true;
344
345 update_option('xs_counter_' . $k . '_token', $setId);
346 update_option('xs_counter_' . $k . '_created', $created);
347 }
348 }
349 }
350 }
351
352 }
353 }
354 ?>
355
356 <div class="wslu-single-popup-item">
357 <div class="setting-label-wraper">
358 <label class="setting-label wslu-sec-title"
359 for="xs_<?php echo esc_attr($k); ?>_text">
360 <?php echo esc_html__('Default ' . $setLabel . ' ' . $belowText, 'wp-social'); ?>
361 </label>
362 </div>
363
364 <input name="xs_counter[social][<?php echo esc_attr($k); ?>][data][value]"
365 type="text"
366 id="xs_<?php echo esc_attr($k); ?>_text"
367 value="<?php echo esc_html($belowValue); ?>"
368 class="wslu-global-input">
369 </div>
370
371 <div class="wslu-single-popup-item">
372 <div class="setting-label-wraper">
373 <label class="setting-label wslu-sec-title"
374 for="xs_<?php echo esc_attr($k); ?>_text"> <?php echo esc_html__('Text Below The Number', 'wp-social'); ?></label>
375 </div>
376
377 <input name="xs_counter[social][<?php echo esc_attr($k); ?>][data][text]" type="text"
378 id="xs_<?php echo esc_attr($k); ?>_text"
379 value="<?php echo esc_html($belowText); ?>"
380 class="wslu-global-input">
381 </div>
382
383 <div class="wslu-single-popup-item">
384 <div class="setting-label-wraper">
385 <label class="setting-label wslu-sec-title"
386 for="xs_<?php echo esc_attr($k); ?>_label"> <?php echo esc_html__('Label Name', 'wp-social'); ?></label>
387 </div>
388 <input name="xs_counter[social][<?php echo esc_attr($k); ?>][label]" type="text"
389 id="xs_<?php echo esc_attr($k); ?>_label"
390 value="<?php echo esc_html($setLabel); ?>" class="wslu-global-input">
391 </div>
392
393 <div class="wslu-single-popup-item">
394 <?php
395
396 if(!in_array($k, ['posts', 'comments'])):
397
398 $provider = strtolower($k);
399 $username = '';
400
401 if($k == 'pinterest') {
402
403 $username = empty($counter_provider[$k]['username']) ? '' : sanitize_key($counter_provider[$k]['username']);
404 // todo - again some bujruki, need time to cleanup this shit
405
406 } elseif(in_array($k, ['youtube', 'twitter'])) {
407 $username = empty($counter_provider[$provider]['id']) ? '' : sanitize_key($counter_provider[$provider]['id']);
408 }
409
410 $time = get_option('_xs_social_' . $k . '_last_cached', 0);
411
412 $ago = empty($time) ? esc_html__('No cache found', 'wp-social') : human_time_diff($time, time()) . ' ' . esc_html__('ago', 'wp-social');
413
414 ?>
415
416 <div class="wslu-catch-clear">
417 <button type="button"
418 class="wslu-catch-clear--btn"
419 onclick="wp_social_clear_cache('<?php echo esc_attr($k) ?>', '<?php echo esc_attr($username) ?>')">
420 <?php echo esc_html__('Clear', 'wp-social') ?>
421 </button>
422
423 <span class="wslu-catch-clear--text" id="<?php echo esc_attr($k) ?>_cache_msg">
424 <?php echo esc_html(__('Cached : ', 'wp-social') . $ago); ?>
425 </span>
426 </div>
427
428 <?php endif; ?>
429 </div>
430 </div>
431
432 </div>
433
434 </div>
435
436 <?php
437
438 if($k == 'posts' || $k == 'comments') {
439
440 ?>
441 <p style="color: #b5b512;">* If default value is given actual value will not show</p>
442 <?php
443 }
444
445 ?>
446 <div class="xs-modal-footer">
447 <button type="submit" name="counter_settings_submit_form"
448 class="xs-btn btn-special"><?php echo esc_html__('Save Changes', 'wp-social'); ?></button>
449 </div>
450 </div>
451 </div>
452
453 <?php
454 }
455 $m++;
456 endforeach;
457 ?>
458 </div>
459
460 </form>
461
462 <div class="xs-counter-popup-access-box">
463 <?php
464
465 if(is_array($filed)) {
466
467 foreach($filed as $fk => $fv) :
468
469 $apiCheck = isset($fv['api']) ? $fv['api'] : '';
470
471 if(is_array($apiCheck)) {
472 $name = isset($apiCheck['label']) ? $apiCheck['label'] : 'Key';
473 $filedApi = isset($apiCheck['filed']) ? $apiCheck['filed'] : '';
474
475 $popupLabel = (isset($counter_provider[$fk]['label']) && strlen($counter_provider[$fk]['label']) > 2) ? $counter_provider[$fk]['label'] : ucfirst($fk);
476 ?>
477 <form method="post"
478 action="<?php echo esc_url(admin_url() . 'admin.php?page=wslu_counter_setting&tab=wslu_providers&xs_access=' . $fk . ''); ?>">
479 <div class="xs-modal-dialog" id="example-modal-<?php echo esc_attr($fk); ?>">
480 <div class="xs-modal-content post__tab">
481 <div class="xs-modal-header clear-both">
482 <div class="tabHeader">
483 <ul class="tab__list clear-both"></ul>
484 </div>
485 <button type="button" class="xs-btn" data-modal-dismiss="modal">
486 <span class="wslu-icon met-social met-social-cross"></span>
487 </button>
488 </div>
489 <div class="xs-modal-body">
490 <div class="ekit--tab__post__details tabContent">
491 <div class="wslu-popup-data">
492 <?php
493 if(is_array($filedApi)) {
494 foreach($filedApi as $fkl => $fvl) {
495 $valueAPp = get_option('xs_counter_' . $fk . '_' . $fkl) ? get_option('xs_counter_' . $fk . '_' . $fkl) : '';
496 ?>
497 <div class="wslu-single-popup-item">
498 <div class="setting-label-wraper">
499 <label class="setting-label wslu-sec-title"
500 for="xs_<?php echo esc_attr($fk); ?>_<?php echo esc_attr($fkl); ?>">
501 <?php echo esc_html__($fvl, 'wp-social'); ?>
502 </label>
503 </div>
504
505 <input type="text"
506 name="accesskey[<?php echo esc_attr($fk); ?>][<?php echo esc_attr($fkl); ?>]"
507 class="wslu-global-input"
508 id="xs_<?php echo esc_attr($fk); ?>_<?php echo esc_attr($fkl); ?>"
509 value="<?php echo esc_attr($valueAPp); ?>">
510 </div>
511 <?php
512 }
513 }
514 ?>
515 </div>
516 </div>
517 <?php
518 if($fk == 'instagram') {
519 $cur_page = admin_url() . 'admin.php?page=wslu_counter_setting&tab=wslu_providers&xs_access=' . $fk . '';
520 ?>
521 <p class="document"><?php echo esc_html__('Go to APP Settings and Set Callback URL', 'wp-social'); ?>
522 <a href="<?php echo esc_url('https://www.instagram.com/developer/clients/manage/'); ?>"> <?php echo esc_html__('App Settings ', 'wp-social'); ?></a>
523 </p>
524 <p class="document"><?php echo esc_html__('Add the following URL to the "Valid OAuth redirect URIs" field:', 'wp-social'); ?>
525 <strong><?php echo esc_url($cur_page); ?></strong></p>
526 <?php }
527 if($fk == 'linkedin') {
528 $cur_page = admin_url() . 'admin.php?page=wslu_counter_setting&tab=wslu_providers&xs_access=' . $fk . '';
529 ?>
530 <p class="document"><?php echo esc_html__('Go to APP Settings and Set Callback URL', 'wp-social'); ?>
531 <a href="<?php echo esc_url('https://www.linkedin.com/developers/'); ?>"> <?php echo esc_html__('App Settings ', 'wp-social'); ?></a>
532 </p>
533 <p class="document"><?php echo esc_html__('Add the following URL to the "Valid OAuth redirect URIs" field:', 'wp-social'); ?>
534 <strong><?php echo esc_url($cur_page); ?></strong></p>
535 <?php }
536 if($fk == 'dribbble') {
537 $cur_page = admin_url() . 'admin.php?page=wslu_counter_setting&tab=wslu_providers&xs_access=' . $fk . '';
538 ?>
539 <p class="document"><?php echo esc_html__('Go to APP Settings and Set Callback URL', 'wp-social'); ?>
540 <a href="<?php echo esc_url('https://dribbble.com/account/applications/'); ?>"> <?php echo esc_html__('App Settings ', 'wp-social'); ?></a>
541 </p>
542 <div class="document"><?php echo esc_html__('Add the following URL to the "Valid OAuth redirect URIs" field:', 'wp-social'); ?>
543 <pre style="width: 500px; overflow:scroll; font-weight:bold; padding:10px 10px 10px 0; color:brown"><?php echo esc_url($cur_page); ?></pre>
544 </div>
545 <?php } ?>
546 </div>
547 <div class="xs-modal-footer">
548 <button type="submit" name="xs_provider_submit_form_access_counter"
549 class="xs-btn btn-special"><?php echo esc_html__('Generate Key', 'wp-social'); ?></button>
550 </div>
551 </div>
552 </div>
553 </form>
554 <?php }
555 endforeach;
556 } ?>
557 <div class="xs-backdrop <?php echo esc_attr(strlen($getType) > 1 && isset($_GET['code']) ? 'is-open' : ''); ?>"></div>
558 </div>
559 </div>
560