ID = $ID; } public function get_html() { $form = $this; /** * Filters the CSS classes to be added to this form's class attribute. * * @param array $form_classes * @param Form $form */ $form_classes_attr = apply_filters( 'hf_form_element_class_attr', '', $form ); /** * Filters the action attribute for this form. * * @param string $form_action * @param Form $form */ $form_action = apply_filters( 'hf_form_element_action_attr', null, $form ); $form_action_attr = is_null( $form_action ) ? '' : sprintf('action="%s"', $form_action ); $html = ''; $html .= sprintf( '', HTML_FORMS_VERSION, 'https://wordpress.org/plugins/html-forms/' ); $html .= sprintf( '
'; $html .= ''; /** * Filters the resulting HTML for this form. * * @param string $html * @param Form $form */ $html = apply_filters( 'hf_form_html', $html, $form ); return $html; } /** * @return string */ public function __toString() { return $this->get_html(); } /** * @return array */ public function get_required_fields() { if( empty( $this->settings['required_fields'] ) ) { return array(); } $required_fields = explode( ',', $this->settings['required_fields'] ); return $required_fields; } /** * @return array */ public function get_email_fields() { if( empty( $this->settings['email_fields'] ) ) { return array(); } $email_fields = explode( ',', $this->settings['email_fields'] ); return $email_fields; } /** * @param string $code */ public function get_message( $code ) { $form = $this; $message = isset( $this->messages[ $code ] ) ? $this->messages[ $code ] : ''; /** * @param string $message * @param Form $form */ $message = apply_filters( 'hf_form_message_' . $code, $message, $form ); return $message; } }