I’m working with a plugin called SEO Ultimate where there is the following class:
class SU_Titles extends SU_Module {
function init() {
......
}
function change_title_tag($head) {
......
}
......
}
I want to override the function change_title_tag
and have managed to override it using the following code:
Class SU_Titles_Extended extends SU_Titles
{
function change_title_tag($head) {
$title = $this->get_title();
if (!$title) return $head;
// Pre-parse the title replacement text to escape the $ ($n backreferences) when followed by a number 0-99 because of preg_replace issue
$title = preg_replace('/$(d)/', '\$$1', $title);
//Replace the old title with the new and return
$title = do_shortcode($title);
$title .= "<!--- IF YOU CAN SEE THIS, IT IS WORKING -->";
return preg_replace('/<title>[^<]*</title>/i', '<title>'.$title.'</title>', $head);
}
}
remove_action( 'after_setup_theme', array( 'SU_Titles', 'change_title_tag' ) );
add_action( 'after_setup_theme', array( 'SU_Titles_Extended', 'change_title_tag' ), 99 );
However this causes a Fatal error: Using $this when not in object context. (caused on the first line of my override function).
Does anyone have any ideas?
Thanks!