Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

How can I create a plugin to add custom php code right before the </body> tag

0 votes
148 views
asked Nov 23, 2016 in Plugins by dave12
I need to add custom php code for the facebook pixel and analytics. I need to be able to add variables using php.

1 Answer

+3 votes
answered Nov 23, 2016 by pupi1985

Firstly, read the plugin creation guideline: http://docs.question2answer.org/plugins/tutorial/

Then, read the layers documentation: http://docs.question2answer.org/plugins/layers/

You just need to override the body_footer function or, even better, just set the layer's content array for the key 'body_footer'. E.G.:

if (!isset($this->content['body_footer'])) {
    $this->content['body_footer'] = '';
}
$this->content['body_footer'] .= '<script> ... </script>';

...