@@ 161-178 (lines=18) @@ | ||
158 | * @param array $new_instance |
|
159 | * @return array |
|
160 | */ |
|
161 | public function update( $new_instance ) |
|
162 | { |
|
163 | if($this->can_update()) |
|
164 | { |
|
165 | $old_instance = $this->get_old_instance(); |
|
166 | $this->values = $this->form->update($new_instance, $old_instance); |
|
167 | ||
168 | \update_option($this->config['slug'], $this->values); |
|
169 | ||
170 | return $this->results_array( |
|
171 | $this->get_errors(), |
|
172 | $this->values |
|
173 | ); |
|
174 | } |
|
175 | return $this->results_array( |
|
176 | array("You don't have permission to manage options on this site") |
|
177 | ); |
|
178 | } |
|
179 | ||
180 | /** |
|
181 | * Ajax callback internally used to reset all component values to their |
|
@@ 210-230 (lines=21) @@ | ||
207 | * @param string $slug |
|
208 | * @return void |
|
209 | */ |
|
210 | public function reset_section( $slug ) |
|
211 | { |
|
212 | if($this->can_update()) |
|
213 | { |
|
214 | $old_instance = $this->get_old_instance(); |
|
215 | $final_instance = $this->form->reset_components($this->get_section_fields($slug)); |
|
216 | ||
217 | // Array merge is needed in order not to delete fields from other sections |
|
218 | // since the $final_instance only contains the fields that were reset |
|
219 | $this->values = array_merge($old_instance, $final_instance); |
|
220 | \update_option($this->config['slug'], $this->values); |
|
221 | ||
222 | return $this->results_array( |
|
223 | array(), |
|
224 | $this->values |
|
225 | ); |
|
226 | } |
|
227 | return $this->results_array( |
|
228 | array("You don't have permission to manage options on this site") |
|
229 | ); |
|
230 | } |
|
231 | ||
232 | /** |
|
233 | * Renders Amarkal's credits on the page's footer. |