/** * Walk through each child and render it * * @param WP_Form $form * @return string */ protected function render_children(WP_Form $form) { $children = ''; foreach ($form->get_children() as $child) { $children .= $this->render_child($child); } return $children; }
protected function validate() { if (isset($this->errors)) { return; // already validated, and data is immutable } $this->errors = new WP_Error(); $validators = $this->form->get_validators(); foreach ($validators as $callback) { call_user_func($callback, $this, $this->form); } }
/** * @param string $form_id * * @return WP_Form * @throws BadFunctionCallException * @throws InvalidArgumentException */ public function get_form($form_id) { if (!isset($this->registered_forms[$form_id])) { throw new InvalidArgumentException(sprintf(__('Form %s is not registered.', 'wp-forms'), $form_id)); } if (!is_callable($this->registered_forms[$form_id])) { throw new BadFunctionCallException(sprintf(__('Invalid callback for form %s', 'wp-forms'), $form_id)); } $args = func_get_args(); $argument_hash = md5(serialize($args)); if (!isset($this->instantiated_forms[$form_id][$argument_hash])) { $form = new WP_Form($form_id); // The form that we'll we working with today $form->setup_nonce_fields(); $args[0] =& $form; // replace form ID with the form // build the form call_user_func_array($this->registered_forms[$form_id], $args); do_action_ref_array('wp_form_get_form', $args); $this->instantiated_forms[$form_id][$argument_hash] = $form; } return $this->instantiated_forms[$form_id][$argument_hash]; }
/** * @return mixed */ function form_html_name() { return $this->form->html_name(); }