Skip to content

Method

Displays the widget admin form

form( $instance )

public

Parameters

$instance

Source

public function form( $instance ) {
    $instance = wp_parse_args( $instance, $this->defaults() );

    $actions = wp_list_filter(
        tml_get_actions(),
        array(
            'show_in_widget' => true,
        )
    );
    ?>

    <p>
        <label for="<?php echo esc_attr( $this->get_field_id( 'action' ) ); ?>"><?php esc_html_e( 'Action' ); // phpcs:ignore WordPress.WP.I18n.MissingArgDomain -- reuses WP core's translated "Action" string verbatim, not a TML-specific string. ?>
            <select class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'action' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'action' ) ); ?>">
                <?php foreach ( $actions as $action ) : ?>
                    <option value="<?php echo esc_attr( $action->get_name() ); ?>"<?php selected( $action->get_name(), $instance['action'] ); ?>><?php echo esc_html( $action->get_title() ); ?></option>
                <?php endforeach; ?>
            </select>
        </label>
    </p>

    <p>
        <input class="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'show_links' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'show_links' ) ); ?>" type="checkbox" value="1"<?php checked( ! empty( $instance['show_links'] ) ); ?> />
        <label for="<?php echo esc_attr( $this->get_field_id( 'show_links' ) ); ?>"><?php esc_html_e( 'Show action links?', 'theme-my-login' ); ?></label>
    </p>

    <?php
}

Uses

Changelog

VersionDescription
6.0 Introduced.