/** * Adds hidden fields to the start of the donation form. * * @param Charitable_Form $form * @return void * @access public * @since 1.0.0 */ public function add_hidden_fields($form) { if (!$form->is_current_form($this->id)) { return false; } $this->nonce_field(); ?> <input type="hidden" name="charitable_action" value="<?php echo esc_attr($this->form_action); ?> " /> <input type="hidden" name="login" value="<?php echo esc_attr($this->login); ?> " autocomplete="off" /> <input type="hidden" name="key" value="<?php echo esc_attr($this->key); ?> " /> <?php }
/** * Render a form field. * * @param array $field * @param string $key * @param Charitable_Form $form * @param int $index * @return boolean False if the field was not rendered. True otherwise. * @access public * @since 1.0.0 */ public function render_field($field, $key, $form, $index = 0, $namespace = null) { if (!$form->is_current_form($this->id)) { return false; } if (!isset($field['type'])) { return false; } $input_name = is_null($namespace) ? $key : $namespace . '[' . $key . ']'; $field['key'] = apply_filters('charitable_form_field_key', $input_name, $key, $namespace, $form, $index); /* Allows extensions/themes to plug in their own template objects here. */ $template = apply_filters('charitable_form_field_template', false, $field, $form, $index); /* Fall back to default Charitable_Template if no template returned or if template was not object of 'Charitable_Template' class. */ if (!$this->is_valid_template($template)) { $template = new Charitable_Template($this->get_template_name($field), false); } if (!$template->template_file_exists()) { return false; } $template->set_view_args(array('form' => $this, 'field' => $field, 'classes' => $this->get_field_classes($field, $index))); $template->render(); return true; }