PluginProbe
Social Share Buttons / 1.18
Social Share Buttons v1.18
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 / pinterest.php

pinterest.php in Social Share Buttons 1.18, at classes/network/pinterest.php

48 lines 1.2 KB
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 pinterestNetwork extends mbNetwork
6 {
7 protected $network = 'pinterest';
8 protected $icon = 'fa-pinterest';
9 protected $priority = 'readmore';
10 protected $color = '#cb2027';
11
12 public function __construct()
13 {
14 $this->label = __('Share', 'mbsocial');
15 $this->share_url = 'https://www.pinterest.com/pin/create/bookmarklet/?media={img}&url={url}&is_video=false&description={title}';
16 $this->count_api = 'https://api.pinterest.com/v1/urls/count.json?url={url}';
17 $this->profile_url = 'http://www.pinterest.com/{profile}';
18 $this->countable = true;
19 $this->return_var = 'count';
20 $this->popup_dimensions = array(750, 500);
21 parent::__construct();
22
23 }
24
25 public function remoteRequest($url)
26 {
27 $response = wp_remote_get($url);
28
29 if (is_wp_error($response) || $response['response']['code'] != 200) {
30 return false;
31 }
32 else {
33 $result = wp_remote_retrieve_body($response);
34 }
35
36 // remove the callback wrapper.
37 $result = str_replace("receiveCount(","",$result);
38 $result = substr($result,0,(strlen($result) -1) ); // remove last char.
39 $json = json_decode($result, true);
40
41 if (isset($json["count"]))
42 return $json["count"];
43
44 return 0;
45 }
46
47 }
48