Skip to content

Instantly share code, notes, and snippets.

@etki
Last active August 29, 2015 14:25
Show Gist options
  • Save etki/7e3b95f116907dc1efc4 to your computer and use it in GitHub Desktop.
Save etki/7e3b95f116907dc1efc4 to your computer and use it in GitHub Desktop.
A loop for WordPress wp-forms plugin
<?php
class WP_Form implements WP_Form_Aggregate, WP_Form_Attributes_Interface
{
public function getElements()
{
$elements = [];
foreach ($this->elements as $element) {
$dataBuffer = $element->getAttributes();
if ($element instanceof WP_Form_Aggregate) {
$dataBuffer['elements'] = $element->getElements();
}
$elements[] = $dataBuffer;
}
return $elements;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment