Skip to content

Instantly share code, notes, and snippets.

@ramiy
Last active August 29, 2015 14:23
Show Gist options
  • Save ramiy/0b9c9405e7711be0ac0e to your computer and use it in GitHub Desktop.
Save ramiy/0b9c9405e7711be0ac0e to your computer and use it in GitHub Desktop.
<?php
// Current
public function get_values() {
foreach ( $this->tabs as $tab => $settings ) {
foreach ( $settings['fields'] as $fields ) {
foreach ( (array)$fields as $f ) {
if ( isset( $f['name'] ) )
$this->parameters[$f['name']] = $this->get_value($f);
elseif($f['type'] == 'selects' && isset($f['selects'])) {
foreach ($f['selects'] as $select) {
$this->parameters[$select['name']] = $this->get_value($select);
}
}elseif($f['type'] == 'checkboxes' && isset($f['options'])) {
foreach ((array)$f['options'] as $key => $value) {
$this->parameters[$key] = $this->get_value(array('name' => $key));
}
}elseif($f['type'] == 'texts' && isset($f['texts'])) { //texts field type
foreach ((array)$f['texts'] as $key => $f) {
$this->parameters[$f['name']] = $this->get_value($f);
}
}
}
}
}
}
// New
public function get_values() {
foreach ( $this->tabs as $tab => $settings ) {
foreach ( $settings['fields'] as $fields ) {
foreach ( (array)$fields as $f ) {
if ( isset( $settings['multiple'] ) ) // Changing the inner $f['name'] with parent $settings['multiple']
$this->parameters[$f['name']] = $this->get_value($f);
elseif($f['type'] == 'selects' && isset($f['selects'])) {
foreach ($f['selects'] as $select) {
$this->parameters[$select['name']] = $this->get_value($select);
}
}elseif($f['type'] == 'checkboxes' && isset($f['options'])) {
foreach ((array)$f['options'] as $key => $value) {
$this->parameters[$key] = $this->get_value(array('name' => $key));
}
}elseif($f['type'] == 'texts' && isset($f['texts'])) { //texts field type
foreach ((array)$f['texts'] as $key => $f) {
$this->parameters[$f['name']] = $this->get_value($f);
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment