Skip to content

Instantly share code, notes, and snippets.

@b0r1sp
Forked from uberboom/CleanSource.php
Created February 23, 2016 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b0r1sp/7668a787839d3f1287a5 to your computer and use it in GitHub Desktop.
Save b0r1sp/7668a787839d3f1287a5 to your computer and use it in GitHub Desktop.
TYPO3: Hook to remove the generator meta tag (TYPO3 CMS 6.2)
<?php
namespace Your\Extension\Namespace\Hooks;
/**
* Clean up source
*/
class CleanSource extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin
{
/**
* No cache
*
* @return void
*/
public function contentPostProcOutput(&$params, &$that)
{
if (!$GLOBALS['TSFE']->isINTincScript()) {
return;
}
$this->_removeGenerator($params['pObj']->content);
}
/**
* Cached
*
* @return void
*/
public function contentPostProcAll(&$params, &$that)
{
if ($GLOBALS['TSFE']->isINTincScript()) {
return;
}
$this->_removeGenerator($params['pObj']->content);
}
/**
* Remove generator meta tag
* <meta name="generator" content="TYPO3 6.2 CMS">
*
* @return void
*/
private function _removeGenerator(&$content)
{
$content = preg_replace('/<meta name="?generator"?.+?>/is', '', $content);
}
}
<?php
// hook is called after caching (for modification of pages with COA_/USER_INT objects)
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-output'][] = 'Your\\Extension\\Namespace\\Hooks\\CleanSource->contentPostProcOutput';
// hook is called before caching (for modification of pages on their way in the cache)
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['contentPostProc-all'][] = 'Your\\Extension\\Namespace\\Hooks\\CleanSource->contentPostProcAll';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment