Add attribute to all textboxes in the site
You'll want to use hook_field_widget_WIDGET_TYPE_form_alter() for this. The following will add the "my-class" class to all textfields:

/**
 * Implements hook_field_widget_WIDGET_TYPE_form_alter().
 */
function test_field_widget_text_textfield_form_alter(&amp;$element, &amp;$form_state, $context) {
  $element['value']['#attributes']['class'][] = 'my-class';
}