Programmatically set view header I know there is a post on how to set a view header/footer value here,
but how do I set a view header/footer without having to create it through views UI first?

The reason why I want to implement a view header programmatically is because (a) I want to write php code in it, by leveraging the Drupal's API, something that is not so convenient in a textarea field, like the one that the views UI provides -and any other textarea field- plus the fact that some functions may never get invoked and (b) because I want to conditionally set/unset the view header/footer.
After some research I managed to answer my own question by implementing the hook_views_pre_view in my custom module. The method set_item is used to set the configuration of an item (field/sort/filter/etc) on a given display. The $print variable bares the content to be rendered in the view header, it is just an example and it can be replaced by anything. Apparently now I can take advantage of the Drupal API or even set/unset any view item conditionally.

/**
 * Implementation of hook_views_pre_view.
 */
function my_module_views_pre_view(&amp;$view, &amp;$display_id, &amp;$args) {

  $path = $_GET['q'];
  // Construct the print link.
  $print = l(t('Display a printer-friendly version of this page'), '/print/' . $path . '/print-friendly',  array(
    'attributes' =&gt; array(
      'class' =&gt; array('print-friendly'),
      'target' =&gt; '_blank',
      'title'=&gt; t('Display a printer-friendly version of this page.'),
      ),
    )
  );

  if ($view-&gt;name == 'my_view_name' &amp;&amp; $display_id == 'my_view_display') {
    // View's header declaration.
    $item = array(
      'id' =&gt; 'area',
      'table' =&gt; 'views',
      'field' =&gt; 'area',
      'relationship' =&gt; 'none',
      'group_type' =&gt; 'group',
      'ui_name' =&gt; '', 
      'label' =&gt; '',
      'empty' =&gt; 0,
      'content' =&gt; $print,
      'format' =&gt; 'filtered_html',
      'tokenize' =&gt; 0,
    );
    // Render the header.
    $view-&gt;set_item($display_id, 'header', 'area', $item);
  }
}