PluginProbe
Social Share Buttons / 0.9
Social Share Buttons v0.9
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 0.9, at classes/network/vk.php

43 lines 911 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
11
12 public function __construct()
13 {
14 $this->label = __('Share', 'mbsocial');
15 $this->share_url = 'https://vkontakte.ru/share.php?url={url}';
16 $this->count_api = 'https://vk.com/share.php?act=count&url={url}';
17 $this->countable = true;
18 // count function vKontakteCount
19 }
20
21 public function remoteRequest($url)
22 {
23
24 $response = wp_remote_get($url);
25
26 if (is_wp_error($response) || $response['response']['code'] != 200) {
27 return false;
28 }
29 else {
30 $result = wp_remote_retrieve_body($response);
31 }
32
33 preg_match('/(\d+),\s+(\d+)/i', $result, $matches);
34 if (isset($matches[2])) // 0 is both patterns, one is first number (not used?).
35 { $count = $matches[2];
36 return $count;
37 }
38 return 0;
39
40 }
41
42 }
43