PluginProbe
Social Share Buttons / 1.6
Social Share Buttons v1.6
trunk 0.9 1.0 1.1 1.1.1 1.1.2 1.10 1.11 1.12 1.15 1.16 1.17 1.18 1.19 1.2 1.20 1.3 1.30 1.4 1.5 1.6 1.7 1.8 1.9
share-button / classes / network / vk.php

vk.php in Social Share Buttons 1.6, at classes/network/vk.php

49 lines 998 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace MBSocial;
3
4
5 class vkontakteNetwork extends mbNetwork
6 {
7 protected $network = 'vkontakte';
8 protected $priority = 'readmore';
9 protected $icon = 'fa-vk';
10 protected $color = '#4c75a3';
11
12
13 public function __construct()
14 {
15
16 $this->label = __('Share', 'mbsocial');
17 $this->share_url = 'https://vkontakte.ru/share.php?url={url}';
18 $this->count_api = 'https://vk.com/share.php?act=count&url={url}';
19 $this->profile_url = 'https://vk.com/{profile}';
20
21 $this->countable = true;
22 parent::__construct();
23
24 // count function vKontakteCount
25 }
26
27 public function remoteRequest($url)
28 {
29
30 $response = wp_remote_get($url);
31
32 if (is_wp_error($response) || $response['response']['code'] != 200) {
33 return false;
34 }
35 else {
36 $result = wp_remote_retrieve_body($response);
37 }
38
39 preg_match('/(\d+),\s+(\d+)/i', $result, $matches);
40 if (isset($matches[2])) // 0 is both patterns, one is first number (not used?).
41 { $count = $matches[2];
42 return $count;
43 }
44 return 0;
45
46 }
47
48 }
49