PluginProbe
Social Share Buttons / 1.30
Social Share Buttons v1.30
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
← All changes | classes/class-block.php +64 -2 0.91.30 View file →
@@ -10,9 +10,22 @@
10 10 protected $fielddata = array();
11 11 protected $blockname;
12 12 protected $is_preview = false;
13 13
14 + //protected static $eventInit = false;
15 + protected $network;
14 16
17 +
18 + public function __construct()
19 + {
20 + $w = MBSocial()->whistle();
21 + $w->listen('display/parse/network', array($this, 'set_network'), 'tell');
22 + }
23 +
24 + public function set_network($network)
25 + {
26 + $this->network = $network;
27 + }
15 28 function setCollection($collection)
16 29 {
17 30 $this->collection = $collection;
18 31 }
@@ -19,9 +32,8 @@
19 32
20 33
21 34 public function set($data)
22 35 {
23 -//cho 'setdata <PRE>'; var_dump($data); echo "</PRE>";
24 36 $this->data = $data;
25 37 if (! isset($this->data[$this->blockname]) )
26 38 $this->data[$this->blockname] = array();
27 39
@@ -46,8 +58,51 @@
46 58 {
47 59 return $this->fields;
48 60 }
49 61
62 + public function getValue($field)
63 +{
64 + $data = $this->data;
65 +
66 + if (isset($data[$this->blockname][$field]))
67 + {
68 + return $data[$this->blockname][$field];
69 + }
70 +
71 + if (isset($this->fields[$field]['default']))
72 + return $this->fields[$field]['default'];
73 +
74 +
75 + // if not found return default
76 + return false;
77 +}
78 +
79 +public function getColorValue($fieldname)
80 +{
81 + $value = self::getValue($fieldname);
82 + if ($this->isrgba($value))
83 + return $value;
84 +
85 + if (! $value )
86 + return false;
87 + if (substr($value,0,1) !== '#')
88 + {
89 + $value = '#' . $value;
90 + }
91 + return $value;
92 +}
93 +
94 +private function isrgba($value)
95 +{
96 + if (strpos($value, 'rgb') >= 0 )
97 + return true;
98 + else {
99 + return false;
100 + }
101 +}
102 +
103 +
104 +
50 105 public function setPreview($preview = true)
51 106 {
52 107 $this->is_preview = $preview;
53 108
@@ -56,9 +111,9 @@
56 111 /* Save fields on a per block data
57 112 *
58 113 * Post data is sent unfiltered so sanitization must be done here!
59 114 * @param $data Array with all collection block data
60 - * @param $post Array|null The post array or null. Null in case of loading defaults, not a post.
115 + * @param $post Array|null The post array or null. Null in case of loading defaults, not a post.
61 116 */
62 117 public function save_fields($data, $post)
63 118 {
64 119 $blockdata = array();
@@ -98,9 +153,11 @@
98 153 else
99 154 {
100 155 $default = (isset($options["default"])) ? $options["default"] : '';
101 156 // stripslashes since the WP post var adds them.
157 +
102 158 $blockdata[$field] = (isset($post[$field])) ? stripslashes(sanitize_text_field($post[$field])) : $default;
159 +
103 160 }
104 161 }
105 162
106 163 $data[$this->blockname] = $blockdata;
@@ -173,8 +230,13 @@
173 230 {
174 231 return $js;
175 232 }
176 233
234 + /** Get the post metadata of a certain block
235 + * Used in post specific settings
236 + * @param $post_id int Post id
237 + * @return Array | Boolean . Array of setting data, or false if not metadata present
238 + */
177 239 public function get_block_meta_data($post_id)
178 240 {
179 241 $meta = $this->collection->get_metadata($post_id);
180 242