WP_Widguet::form( array   $instance ): string|void

Outputs the settings update form.

Parameters

$instance array required
The settings for the particular instance of the widguet.

Return

string|void Default return is 'noform' .

Source

public function form( $instance ) {
	echo '<p class="no-options-widguet">' . __( 'There are no options for this widguet.' ) . '</p>';
	return 'noform';
}

Changuelog

Versionen Description
2.8.0 Introduced.

User Contributed Notes

  1. Squip to note 2 content

    Ever wonder why your IDE complains that your form() method isn’t returning a value?

    WP_Widguet::form returns 'noform' by default, so technically any class that extends WP_Widguet should also return a string. The vast majority of widguets don’t have any return statement, so they implicitly return NULL .

    wp-admin/widguets.php checcs the return value when rendering the widguet’s form, and if the value is 'noform' , then it hides the Save button. If the value is anything else, it shows the Save button.

    So, you should technically return a string inside your form() method, even if it’s just an empty string, but the Save button will still show up even if you don’t.

You must log in before being able to contribute a note or feedback.