Skip to content
Advertisement

Insert CSS into html header via php Function

I have access to creating hooks to edit the appearance of websites, but no experience with php. The hooks manpage gives examples such as:

JavaScript

Now, what I want to do is insert the following CSS into this function (the function is executed before rendering the page) so that instead of printing a message as above, it makes all print elements empty and prevents selecting and copying text. I found these CSS elements elsewhere that do that, but I don’t know how they need to be put into the function to then be applied to the final page:

JavaScript

and

JavaScript

Advertisement

Answer

In your php code, create a variable and then define the CSS style tag and css within the variable, there is no need to declare a function for this simple code, also the style tag goes within the head. Use the function along with the php variable if you need the function code as well.

JavaScript

HTML in your PHP file

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement