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 / pinterest.php

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

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