PluginProbe
Social Share Buttons / 1.1.2
Social Share Buttons v1.1.2
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-admin.php +43 -9 0.91.1.2 View file →
@@ -17,12 +17,15 @@
17 17
18 18 }
19 19
20 20 // add a maxfield to be displayed on the admin.
21 - public function addfield( $field, $start = '', $end = '')
21 + public function addfield( $field, $start = '', $end = '', $trigger_update = true)
22 22 {
23 23 $field_id = isset($field->id) ? $field->id : $field->template . \rand(0,1000);
24 -
24 + if ($trigger_update)
25 + {
26 + $this->addUpdate($field); // make updating standard
27 + }
25 28 $field->publish = false; // Output fields via class - never output.
26 29
27 30 $this->fields[$field_id] = array('field' => $field,
28 31 'start' => $start,
@@ -35,11 +38,16 @@
35 38
36 39 public function addUpdate($field)
37 40 {
38 41 $field_id = $field->id;
39 - $this->defined_updatable[] = $field_id;
42 + if (is_null($field_id) || $field_id == '')
43 + return; // no bad names
44 +
45 + if (! isset($this->defined_updatable[$field_id])) // no double sets
46 + $this->defined_updatable[] = $field_id;
40 47 }
41 48
49 +
42 50 public function namespaceit($var)
43 51 {
44 52 return self::$namespace . $var;
45 53 }
@@ -55,10 +63,8 @@
55 63 $field = $item['field'];
56 64 $output .= $field->output($item['start'], $item['end']);
57 65 }
58 66
59 -
60 -
61 67 // auto-update system
62 68 $updatable = $this->defined_updatable;
63 69 foreach($updatable as $index => $field)
64 70 {
@@ -90,8 +96,12 @@
90 96
91 97 /** @param $active_networks - Networks that were saved by the users. This should be loaded instead of the default ones **/
92 98 public function get_default_networks($active_networks = array() )
93 99 {
100 + if (! is_array($active_networks))
101 + {
102 + $active_networks = array();
103 + }
94 104 $networks = mbSocial()->networks()->get();
95 105
96 106 $selected = array();
97 107 $unselected = array();
@@ -96,8 +106,15 @@
96 106 $selected = array();
97 107 $unselected = array();
98 108 $readmore = array();
99 109
110 + // set active networks. Support doubles.
111 + foreach($active_networks as $index => $network_name)
112 + {
113 + $network = mbSocial()->networks()->get($network_name);
114 + $selected[$index] = $network;
115 + }
116 +
100 117 foreach($networks as $index => $network)
101 118 {
102 119 $priority = $network->get('priority');
103 120 $is_active = array_search($network->get('network'), $active_networks); // retrieve the array index
@@ -102,12 +119,18 @@
102 119 $priority = $network->get('priority');
103 120 $is_active = array_search($network->get('network'), $active_networks); // retrieve the array index
104 121
105 122 if ($is_active !== false)
123 + {
106 124 $priority = 'selected';
125 + }
107 126
108 - if ($priority == 'selected')
109 - $selected[$is_active] = $network;
127 + /* if ($priority == 'selected')
128 + {
129 + continue; // ignore active, since it's set earlier.
130 + //$selected[$is_active] = $network;
131 +
132 + } */
110 133 if ($priority == 'unselected')
111 134 $unselected[] = $network;
112 135 if ($priority == 'readmore')
113 136 $readmore[] = $network;
@@ -112,14 +135,19 @@
112 135 if ($priority == 'readmore')
113 136 $readmore[] = $network;
114 137
115 138
116 - }
139 + if ($network->get('network') == 'maxbutton' && $priority != 'readmore') // exceptions
140 + {
141 + $readmore[] = $network;
142 + }
117 143
118 144
145 + } // foreach networks
146 +
147 +
119 148 // Sort networks by order saved.
120 149 ksort($selected);
121 -
122 150 return array('selected' => $selected, 'unselected' => $unselected, 'readmore' => $readmore);
123 151 }
124 152
125 153
@@ -145,8 +173,14 @@
145 173
146 174 public function footer()
147 175 {
148 176 include_once( mbSocial()->get_plugin_path() . '/admin/footer.php');
177 + }
178 +
179 + public function getProMessage()
180 + {
181 + return __( sprintf('You can only change these settings in the PRO version. Click %shere%s for upgrading to MaxButtons PRO', '
182 + <a href="https://maxbuttons.com" target="_blank">', '</a>') );
149 183 }
150 184
151 185
152 186