WordPress.org

Forums

Per page add to head
[resolved] Inserting PHP (3 posts)

  1. rpwk
    Member
    Posted 1 year ago #

    Hi - this plugin would work perfectly for me, however I cannot insert PHP code into the header using this as the tags are getting stripped.

    I'm trying to add a PHP include on a per page basis to the head that interacts with javascript files which load content at the bottom of the page (product reviews.)

    Can you actually add PHP using the plugin or am I completely out of my mind?

    Thanks!

    https://wordpress.org/plugins/per-page-add-to/

  2. Erikvona
    Member
    Plugin Author

    Posted 1 year ago #

    You can't insert PHP into a post or page with this plugin, sorry.

    As far as I know, there are no plugins that can do this. You could try to modify my plugin for this purpose, but the results will probably be unexpected.

    Try changing the following:
    Line 93 through 95 of perpagehead.php:

    if(!empty($addtoheadcontent)){
    	echo stripslashes_deep($addtoheadcontent);
    }

    should be changed to:

    if(!empty($addtoheadcontent)){
    	eval(stripslashes_deep($addtoheadcontent));
    }

    This will cause EVERYTHING you put in the box to be evaluated as PHP (as if it was inside <?php ?> tags , so use ?> HTML here <?php to put html in). However, using the eval() function is usually a bad idea, I haven't tried it, and won't support it. Also, this causes non-admins to be able to execute PHP code on your webserver, so it seriously compromises security (if you can execute PHP, you can empty the SQL database, delete and modify users, promote yourself to admin, take over the site etc.).

    To be short: this is a very bad idea, you shouldn't do this, but if you still want to, this is the way.

  3. rpwk
    Member
    Posted 1 year ago #

    LOL, thanks Erik for the speedy reply. If I could find someway to pass simple variables to the reviews array I could just include it once in the header and then enter the variables on a per page basis but that is a totally different thing. Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Per page add to head
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.