in_widget_form

最后更新于:2021-11-27 02:07:30

do_action_ref_array( ‘in_widget_form’, GC_Widget $widget, null $return, array $instance )

Fires at the end of the widget control form.

参数

$widget

(GC_Widget)
The widget instance (passed by reference).

$return

(null)
响应 null if new fields are added.

$instance

(array)
An array of the widget’s settings.

源文件

文件: gc-includes/class-gc-widget.php

View on Trac

if ( ! function_exists( 'gcdocs_display_custom_field_in_widget_form' ) ) {

    add_action( 'in_widget_form', 'gcdocs_display_custom_field_in_widget_form', 10, 3 );

    /**
     * Append custom field end of the widgets control form
     * Fires at the end of the widget control form.
     */
    function gcdocs_display_custom_field_in_widget_form( $widget, $return, $instance ) {
        $column = isset( $instance['column'] ) ? $instance['column'] : '';

        ob_start();
        ?>

        <p>
            <label for="<?php echo esc_attr( $widget->get_field_id( 'itclan_bs_grid_class' ) ) ?>"><?php _e( 'Column Label', 'text_domain' ) ?>
                <input class="widefat" value="<?php echo esc_attr( $column ) ?>" id="<?php echo esc_attr( $widget->get_field_id( 'column' ) ) ?>" name="<?php echo esc_attr( $widget->get_field_name( 'column' ) ) ?>" type="text" />
                <small><?php _e( 'Some additional description.', 'text_domain' ) ?></small>
            </label>
        </p>

        <?php 
        echo ob_get_clean();
    }
}