Skip to content

Method

Render the entire form with notices and links.

render( array $args = array() )

public

Parameters

$args array Default array()
Optional. An array of arguments for rendering a form.
$container string
The form container element.
$container_class string
The form container class.
$container_id string
The form container ID.
$before string
The content to render before the form.
$after string
The content to render after the form.
$show_links bool
Whether to show the links or not.

Return

string The form markup.

Source

public function render( $args = array() ) {
    $defaults = wp_parse_args(
        $this->render_args,
        array(
            'container'       => 'div',
            'container_class' => 'tml tml-%s',
            'container_id'    => '',
            'before'          => '',
            'after'           => '',
            'show_links'      => true,
            'show_form'       => true,
        )
    );

    /**
     * Fires before rendering a form.
     *
     * @since 7.0.13
     *
     * @param string              $name The form name.
     * @param Theme_My_Login_Form $form The form object.
     */
    do_action( 'tml_render_form', $this->name, $this );

    $args = wp_parse_args( $args, $defaults );

    $output = $args['before'];

    if ( ! empty( $args['container'] ) ) {
        $output .= '<' . $args['container'];
        if ( ! empty( $args['container_id'] ) ) {
            $output .= ' id="' . esc_attr( sprintf( $args['container_id'], $this->name ) ) . '"';
        }
        if ( ! empty( $args['container_class'] ) ) {
            $output .= ' class="' . esc_attr( sprintf( $args['container_class'], $this->name ) ) . '"';
        }
        $output .= ">\n";
    }

    /**
     * Filter the content before the form.
     *
     * @since 7.0.13
     *
     * @param string              $output The output.
     * @param string              $name   The form name.
     * @param Theme_My_Login_Form $form   The form object.
     */
    $output = apply_filters( 'tml_before_form', $output, $this->name, $this );

    $output .= '<div class="tml-alerts">' . $this->render_errors() . '</div>';

    if ( $args['show_form'] ) {
        $output .= $this->render_form();
    }

    /**
     * Filter the content after the form.
     *
     * @since 7.0.13
     *
     * @param string              $output The output.
     * @param string              $name   The form name.
     * @param Theme_My_Login_Form $form   The form object.
     */
    $output = apply_filters( 'tml_after_form', $output, $this->name, $this );

    if ( $args['show_links'] ) {
        $output .= $this->render_links();
    }

    if ( ! empty( $args['container'] ) ) {
        $output .= '</' . $args['container'] . ">\n";
    }

    $output .= $args['after'];

    return $output;
}

Uses

Used by

Changelog

VersionDescription
7.0 Introduced.