Adding a single text input field to a custom Dashboard widget

You need a set of functions to :

  • process datas
  • sanitize options
  • allow datas to be updated
  • output the form

I like to proceed this way. I set also a function to grab datas so I can call them the simpliest way :

add_action('wp_dashboard_setup', 'wpse_106458_add_widget');

function wpse_106458_add_widget() {

  $title = my_function_get_options();
  $title = $title['title'];

  wp_add_dashboard_widget('widget_id', $title, 'callback_output', 'widget_control' );
}

Hope it helps.

EDIT: I wrap it with this :

if ( is_admin() || ( !defined( 'DOING_AJAX' ) || !DOING_AJAX ) ) {/* code goes here */}

This allows to apply code only where it’s necessary.