How to override certain function in a module to disable the return value Not sure how to explain this clearly but let me try.

/**
 * Implementation of hook_footer()  to insert Javascript at the end of the page
 */
function omniture_footer($main = 0) {

  global $user;

    $header = "&lt;!-- SiteCatalyst code version: ";
    $header .=  check_plain(variable_get("omniture_version", 'H.13.'));
    $header .= " Copyright 1997-2009 Omniture, Inc. More info available at http://www.omniture.com --&gt;\n";
    $header .= "&lt;script type=\"text/javascript\" language=\"JavaScript\" src=\"";
    $header .=  check_plain(variable_get("omniture_js_file_location", 'http://www.example.com/js/s_code_remote_h.js'));
    $header .= "\"&gt;&lt;/script&gt;\n";
    $header .= "&lt;script type=\"text/javascript\" language=\"JavaScript\"&gt;&lt;!--\n";

    $footer = '/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/'."\n";
    $footer .= 'var s_code=s.t();if(s_code)document.write(s_code)//--&gt;&lt;/script&gt;'."\n";
    $footer .= '&lt;script language="JavaScript" type="text/javascript"&gt;&lt;!--'."\n";
    $footer .= "if(navigator.appVersion.indexOf('MSIE')&gt;=0)document.write(unescape('%3C')+'\!-'+'-')"."\n";
    $footer .= '//--&gt;&lt;/script&gt;&lt;noscript&gt;&lt;a href="http://www.omniture.com" title="Web Analytics"&gt;&lt;img src="';
    $footer .= check_plain(variable_get("omniture_image_file_location", 'http://examplecom.112.2O7.net/b/ss/examplecom/1/H.13--NS/0')).'/'.rand(0, 10000000).'"'."\n";
    $footer .= 'height="1" width="1" border="0" alt="" /&gt;&lt;/a&gt;&lt;/noscript&gt;&lt;!--/DO NOT REMOVE/--&gt;'."\n";
    $footer .= '&lt;!-- End SiteCatalyst code version: ';
    $footer .=  check_plain(variable_get("omniture_version", 'H.13.'));
    $footer .= ' --&gt;'."\n";

$script  = $header;
$script .= $extra_variables_formatted;
$script .= $footer;

return $script;
}


Now my task is to disable the $script to not show in unpublished articles. Is there any way to do this in template.php preprocess? 

Note: The below solved my question. Its 100% working in my end. Thanks

//Remove omniture tags in unpublish node
  if(arg(0) == 'node' &amp;&amp; $vars['node']-&gt;status == 0) {
    $vars['closure'] = theme('closure');
    $omnitureTags = preg_replace( "/\&lt;!-- SiteCatalyst code version: H\.19\.4 Copyright 1997-2009.+\&lt;!-- End SiteCatalyst code version: H\.19\.4 --\&gt;/si", "", $vars['closure']);
    $vars['closure'] = $omnitureTags;
  } else {
    $vars['closure'] = theme('closure');
  }


Put the above code in preprocess_page.
The value returned from the implementations of hook_footer() is used from theme('closure').

function theme_closure($main = 0) {
  $footer = module_invoke_all('footer', $main);
  return implode("\n", $footer) . drupal_get_js('footer');
}


That function is called from template_preprocess_page(), which uses the following code:

  // Closure should be filled last.
  $variables['closure']           = theme('closure');

  if ($node = menu_get_object()) {
    $variables['node'] = $node;
  }


If you want not to print the value returned by hook_footer(), you have the following options. As you are talking of articles, I get you mean nodes whose content type is "article"; if you used the word articles to mean nodes, then remove the part that checks the value of the type property. 


Empty $variables['closure'] inside a preprocess function, which can be implemented in a module, or a theme (inside template.php). The following code is the code I would write for a theme.

function mytheme_preprocess_page(&amp;$variables) {
  if (!empty($variables['node']) &amp;&amp; $variables['node']-&gt;type == 'article' &amp;&amp; !$variables['node']-&gt;status) {
    $variables['closure'] = '';
  }
}


If you are not interested in the content type of the node, then the code becomes the following one:

function mytheme_preprocess_page(&amp;$variables) {
  if (!empty($variables['node']) &amp;&amp; !$variables['node']-&gt;status) {
    $variables['closure'] = '';
  }
}

In the page.tpl.php file you normally find the following code to print the value returned from hook_footer():

&lt;?php print $closure; ?&gt;


Replace that line with the following one:

&lt;?php if (!empty($node) &amp;&amp; $node-&gt;type != 'article' &amp;&amp; $node-&gt;status): ?&gt;
  &lt;?php print $closure; ?&gt;
&lt;?php endif; ?&gt;


If you just need not to print the value of $closure when a node is not published, independently from the content type of the node, then the code simply becomes:

&lt;?php if (!empty($node) &amp;&amp; $node-&gt;status): ?&gt;
  &lt;?php print $closure; ?&gt;
&lt;?php endif; ?&gt;



In this way, you can remove the value added to $closure from all the implementations of hook_footer(). You can also remove the part added from a specific module, if the module always adds the same string.

If you want to change the value returned from your implementation of hook_footer(), you can use menu_get_object() to get the node object associated to the page, if there is one.

function mymodule_footer() {
  $node = menu_get_object();

  if (!empty($node) &amp;&amp; $node-&gt;type == 'article' &amp;&amp; !$node-&gt;status) {
    return '';
  }

  // Return the value you would return when the node is published.
}