How do I add view header content in code? How do I add view header content in code?

I have seen questions related to this but only where the view is being embedded. I am not embedding any view, but would like to provide content for the view headers in code as I have quite a few views, and I do not want to add the content through the views UI as it is difficult to make changes quickly and as some views have many pages and share the same header.

Currently I have this code.

function MYMODULE_preprocess_views_view(&amp;$vars){
  $function = __FUNCTION__ . '_' . $vars['name'];
  if (function_exists($function)) {
    $function($vars);
  }
}

function MYMODULE_preprocess_views_view_VIEW_NAME(&amp;$vars){
  // do something here.
  $vars['attachment_before'] .= $SOME_CONTENT;
}
Use hook_views_pre_render().

/**
 * Implements hook_views_pre_render().
 */
function cv_views_pre_render(&amp;$view) {
  // dpm($view); // dpm view here to see its properties.
  // and replace $view-&gt;name and $view-&gt;current_display with actual values from your view.
  // Note that my example uses Global: Text area for header, that's why I use $view-&gt;header['area']. 
  // Other options available for header have different names. Try to find one that you use.
  if ($view-&gt;name == 'homepage' &amp;&amp; $view-&gt;current_display = 'homepage_page_display') {
    $view-&gt;header['area']-&gt;options['content'] = t('TEST message');
  }
}